最简单的方法
打开web-inf 下的 web.xml
修改web.xml
/WEB-INF/index.jsp
既然不行那就servlet转发
index.java
public class Index extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//super.doGet(req, resp);
doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//super.doPost(req, resp);
req.getRequestDispatcher("/WEB-INF/index.jsp").forward(req,resp);
}
}
web.xml
indexServlet
com.servletdemo.index.Index
indexServlet
/main/index
结果