2015-07-05 99 views
0

这是我的测试servlet;EL表达未评估

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> 

,输出为$ {name}的

应该写测试1:/这有什么错在于:

回答

0

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

在这个页面上启用EL评估,可以尝试下面的指令在你的JSP文件的顶部:

<%@page isELIgnored="false" %> 
+0

我只是说,但现在的结果是公平的。你好,世界! – cem

+0

所以你看到了改变我的行为?这是一个开始...... – EJK

+0

你是否100%确定你的servlet代码正在执行? – EJK