小编典典

EL表达式未评估

jsp

这是我的测试servlet;

public class EventListServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        process(request, response);
    }

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

    private void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setAttribute("name", "test1");
        request.getRequestDispatcher("index.jsp").forward(request, response);
    }
}

并测试jsp;

<html>
<body>
<h2>Hello World!</h2>
<p>${name}</p>
</body>
</html>

输出为 $ {name}

它应该写成test1:/那是什么问题?


阅读 264

收藏
2020-06-10

共1个答案

小编典典

默认情况下,早期版本的JSP禁用EL。参见:http
:
//docs.oracle.com/cd/E19316-01/819-3669/bnajh/index.html

要在此页面上启用EL评估,请尝试将以下指令放在JSP文件的顶部:

<%@page isELIgnored="false" %>
2020-06-10