这是我的测试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:/那有什么问题???
答案 0 :(得分:0)
早期版本的JSP默认禁用EL。请参阅:http://docs.oracle.com/cd/E19316-01/819-3669/bnajh/index.html
要在此页面上启用EL评估,请尝试将以下指令放在JSP文件的顶部:
{{1}}