怎么找不到文件

来源:1-1 初识EL表达式

weixin_慕瓜9083905

2020-01-02 16:52:57

package com.imooc.el;


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;


/**

 * Servlet implementation class StudentServlet

 */

@WebServlet("/info")

public class StudentServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

       

    /**

     * @see HttpServlet#HttpServlet()

     */

    public StudentServlet() {

        super();

        // TODO Auto-generated constructor stub

    }


/**

* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)

*/

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

Student stu=new Student();

stu.setName("张三");

stu.setMobile(null);

String grade="A";

request.setAttribute("student", stu);

request.setAttribute("grade", grade);

request.getRequestDispatcher("/el_info").forward(request, response);

}


}


<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
	<h1>姓名:${requestScope.student.name }</h1>
	<h2>电话:${requestScope.student.mobile }</h2>
	<h2>评级:${requestScope.grade }</h2>
</body>
</html>


写回答

3回答

好帮手慕酷酷

2020-01-02

同学你好,同学的跳转页面忘记编写后缀名.jsp了。

具体如下:

http://img.mukewang.com/climg/5e0db7d209df511e07410199.jpg

如果我的回答解决了你的疑惑,请采纳!祝学习愉快!

0

好帮手慕酷酷

2020-01-02

同学你好,老师这边测试同学的代码是没有问题,出现404,表示一般是路径的问题,

建议同学检查一下el_info.jsp的位置,应该在WebContent目录下,具体如下:

http://img.mukewang.com/climg/5e0dbce709115a3a02670139.jpg

然后建议同学清除浏览器、eclipse、tomcat缓存再试一下:

浏览器缓存:

http://img.mukewang.com/climg/5e0dbd560902c34005540376.jpg

eclipse缓存:

http://img.mukewang.com/climg/5e0dbd69095d398302510258.jpg

停下Tomcat,右键Clean清除当前的Tomcat缓存:

http://img.mukewang.com/climg/5e0dbd780964c05b04920159.jpg

然后重新运行一下项目。

如果我的回答解决了你的疑惑,请采纳!祝学习愉快!



0

weixin_慕瓜9083905

提问者

2020-01-02

修改了还是不行 输入网站localhost:8080/el/info
还是显示404

0

0 学习 · 9666 问题

查看课程