日期:2014-05-18  浏览次数:20644 次

serlet访问不了jsp为什么
我的jbuilderx写的JSP
<form   name= "form1 "   method= "get "   action= "my_home/LoginServlet "> <h2> 请输入您的用户名   <input   type= "text "   name= "username "   value= " "> </h2> <h2> 请输入您的密码   <input   type= "password "   name= "password "   value= " "> </h2> <h2> 请在次输入您的密码   <input   type= "password "   name= "pawssword2 "   value= " "> </h2> <h2> 请输入您的地址   <input   type= "text "   name= "address "   value= " "> </h2> <h2> 请输入您的电话   <input   type= "text "   name= "phone "   value= " "> </h2> <h2> 请输入您的电子信箱   <input   type= "text "   name= "email "   value= " "> </h2> <input   type= "submit "   name= "提交 "   value= "提交 "   > <input   type= "reset "   name= "重置 "> </form>

我在jbuilderx自动生成LoginServlet:自己重写doget方法

public   void   doGet(HttpServletRequest   request,   HttpServletResponse   response)   throws
ServletException,   IOException   {
response.setContentType(CONTENT_TYPE);
PrintWriter   out=response.getWriter();

request.setCharacterEncoding( "GBK ");
String   username=request.getParameter( "username ");
String   password=request.getParameter( "password ");
String   address=request.getParameter( "address ");
String   phone=request.getParameter( "phone ");
String   email=request.getParameter( "email ");

out.println(username);
out.println(password);
out.println(address);
out.println(phone);
out.println(email);


}

为什么我提交后servlet却接受不到JSP的值??   还报错那,无法完成request的请求

------解决方案--------------------
servlet
------解决方案--------------------
servlet需要在web.xml里面配置
------解决方案--------------------
<servlet>
<servlet-name> 你的Servlet名字 </servlet-name>
<servlet-class> 你的Servlet类放置位置比如com.MyServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> 你上面定义的Servlet名字 </servlet-name>
<url-pattern> 映射例你的/LoginServlet </url-pattern>
</servlet-mapping>
Tomcat以上是在web.xml中设置
然后在你的表单的Action=/Webapps下你的工作文件夹名/LoginServlet
楼主试下看如何!

------解决方案--------------------
jBuiderX 应该自动生成web.xml文件啊