请教各位大哥转向传值的问题
package myweb2;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class userServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK ";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String UserName,UserPass;
UserName=request.getParameter( "UserName ");
UserPass=request.getParameter( "UserPass ");
userBean info = new userBean();
info.setUsername(UserName);
info.setUserpass(UserPass);
user2 s = new user2();
s.inserUserInfo(info);
request.setAttribute( "username ",UserName);
request.setAttribute( "userpass ",UserPass);
//request.getRequestDispatcher( "index.jsp ").forward(request,response);
RequestDispatcher requestDispatcher=request.getRequestDispatcher( "index.jsp ");
requestDispatcher.forward(request,response);
}
//Clean up resources
public void destroy() {
}
}
---------------------------
<%@ page contentType= "text/html; charset=GBK " %>
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=UTF-8 ">
<title> Insert title here </title>
</head>
<body>
<table>
<tr>
<td>
<form method= "post " action= "/myweb/userservlet ">
<input type= "text " name= "UserName ">
<input type= "password " name= "UserPass ">
<input type= "submit " value= "确定 ">
<input type= "reset " value= "重填 ">
</form >
<%
String str1;
str1=(String)request.getAttribute( "username ");
%>
<%=str1%>
</td>
</tr>
</table>
</body>
------------------------------------
为甚么提交后http://localhost:8080/myweb/userservlet不能转倒index.jsp啊?
[解决办法]
/myweb/userservlet
对应的路径是myweb2.userServlet吗?
注意下servlet的路径,