日期:2014-05-17  浏览次数:20773 次

一个简单的servlet例子,tomcat报错求解释
我分两三次把需要的东西发出来


------解决方案--------------------
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}

另外,web.xml要进行配置

 <servlet>
<servlet-name>xxxx</servlet-name>
<servlet-class>包名字.Servlet类名</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>xxxx</servlet-name>
<url-pattern>/addUserServlet</url-pattern>
</servlet-mapping>



------解决方案--------------------
老大,你真狠啊这么多东西真够我们喝一壶的呵呵我感觉也是你的servlet配置出了问题,有一个映射找不到映射名称,至于hibernate 那些信息啊在程序加载的时候,tomcat都不会在开始的时候加载进容器里面,你忘了在web.xml里面有一个配置<startup>,我不是很明白你想知道什么呵呵先说到这里吧
------解决方案--------------------
你好好看看你这段代码对着吗
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

request.setCharacterEncoding("utf-8");
String name=request.getParameter("USERNAME");
String pwd=request.getParameter("USERPASSWORD");
if("aaa".equals(name)&&"111".equals(pwd)){
request.getRequestDispatcher("./success.jsp").forward(request, response);
}else{
request.getRequestDispatcher("./error.jsp").forward(request, response);
}


}

 
 

------解决方案--------------------
把doGET 呢