idea的run------>> edit configurations--------->>Deployment修改Tomcat的Appication Context,加上项目名称,可以解决报404错误,解决路径访问的问题。
开始找了很久,也没发现哪里错误,反复修改web.xml也是没用,以为自己写的路径有问题,访问页面试了很多遍,有时真是费时间。
附上学习过程简单的代码:
**servlet代码:**
public class HelloServlet extends HttpServlet {
private static final long serialVersionUID = 4023442997406361930L;
public HelloServlet(){
super();
}
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException {
PrintWriter out =res.getWriter();
out.println("HelloServlet");
out.close();
}
}
**web.xml简单的配置**
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/