为什么我在manager里面点开是404的?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <%@ page language= "java" contentType= "text/html; charset=utf-8" pageEncoding= "utf-8" %> <%String basePath=request.getScheme()+ ":" + "//" +request.getServerName()+ ":" +request.getServerPort()+ "/" +request.getServletContext().getContextPath()+ "/" ; %> <!DOCTYPE html> <html> <head> <title>Insert title here</title> </head> <body> <center> <form action= "<%=basePath %>LoginServlet" method= "get" > <input type= "submit" value= "提交" > </form> </center> </body> </html> |
http://localhost:8080/imooc_servlet1/NewFile.jsp
http://localhost:8080//imooc_servlet1/LoginServlet
我直接放浏览器能访问到啊?为什么呢?
0
收起
正在回答 回答被采纳积分+1
3回答
chrismorgen
2018-07-27 18:10:13
如下图所示,在标记的位置添加你的欢迎页面文件即可。如果我的建议解决了你的问题,请采纳,祝学习愉快~
chrismorgen
2018-07-27 13:51:32
根据你的描述,我新建一个工程,并将你的jsp页面粘贴到工程中,然后创建一个LoginServlet类,运行工程可以实现跳转,是不会报404的。我的LoginServlet代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet ( "/LoginServlet" ) public class LoginServlet extends HttpServlet{ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub this .doPost(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub System.out.println( "我是doPost方法" ); } } |
同学是在什么情景中找不到页面的,请具体描述问题,方便助教老师据有针对性的帮你解答。祝学习愉快~
从网页搭建入门Java Web2018版
- 参与学习 人
- 提交作业 1088 份
- 解答问题 10204 个
如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧