EL expression not evaluated

时光毁灭记忆、已成空白 提交于 2019-12-12 01:23:21

问题


Here is my test 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);
    }
}

and test jsp ;

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

and the output is ${name}

it should write test1 :/ what's wrong with that ???


回答1:


Earlier versions of JSP disable EL by default. See: http://docs.oracle.com/cd/E19316-01/819-3669/bnajh/index.html

To enable EL evaluation on this page, try putting the following directive at the top of your JSP file:

<%@page isELIgnored="false" %>


来源:https://stackoverflow.com/questions/31231354/el-expression-not-evaluated

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!