我在 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。我在这里做什么错了?
添加回答
举报
0/150
提交
取消