亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 JSP 調用 servlet 時 request.getParameter 中的空值

從 JSP 調用 servlet 時 request.getParameter 中的空值

慕的地8271018 2021-08-13 16:15:21
我在 jps 下面有一個帶有源和目標下拉列表的代碼以及一個將調用 servlet 的按鈕“執行”。服務員將根據選定的值執行一些操作。JSP代碼:<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>    <head>     <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">        <title/>    </head>    <form action="MySourceEnv" method="POST">        <select name="SourceEnv" >                  <option>10.100.10.11</option>                  <option>10.100.10.12</option>              </select>       </form>    <form action="MyDestEnv" method="POST">        <select name="DestEnv" >                  <option>10.100.10.11</option>                  <option>10.100.10.12</option>              </select>       </form>    <body>        <button onclick="location.href = 'http://localhost:7500/Project_1/JavaServlet';" id="RedirectButton" > Execute</button>    </body></html> 服務程序代碼:import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class JavaServletClass extends HttpServlet {    public void init() throws ServletException {    }    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        response.setContentType("text/html");        PrintWriter out = response.getWriter();        String SourceEnvParam = request.getParameter("SourceEnv");        out.println("<h1>" + SourceEnvParam + "</h1>");        LogicMethod(SourceEnvParam);    }    private void LogicMethod(String SourceEnvParam) throws IOException {        // Some logic here    }    public void destroy() {    }}當單擊執行按鈕并調用 servlet 時,我將request.getParameter("SourceEnv") 的值設為 Null。我在這里做什么錯了?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號