问题
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