我将数据从ajax调用传递给特定的JSP页面。 我的login.jsp正在接收值。这是我的jsp
<html>
<head>
<title>Life Settlements</title>
</head>
<body>
<form action="login.ind" method="post">
<%
String username = request.getParameter("loginUserName");
System.out.println("username in jsp\t"+username);
String password = request.getParameter("loginPaswd");
%>
</form>
</html>
JSP是获取用户名和密码值。如何将此值传递给servlet。
我的web.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<servlet>
<servlet-name>ServletR</servlet-name>
<servlet-class>com.ind.servlet.RServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletR</servlet-name>
<url-pattern>*.ind</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
</web-app>
我的servlet有以下服务方法
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String uri=request.getRequestURI();
System.out.println(uri);
if (uri.endsWith("login.ind")) {
page=loginAction.verifyUser(request, response);
}}
答案 0 :(得分:0)
<jsp:forward page="login.jsp" />
<jsp:param name="username" value="Tom"/>