1
我有簡單的servlet將參數傳遞給jsp文件。 下面是代碼:在JSP中未評估EL表達式
String userName = request.getParameter("userName");
HttpSession session = request.getSession();
session.setAttribute("userName", userName);
request.getRequestDispatcher("welcome.jsp").forward(request, response);
頁的welcome.jsp包含:
<body>
<h3 align="center">Welcome ${userName}!!!</h3>
<a href="index.jsp">go back</a>
</body>
中的index.jsp:
<form method="post" action="check">
Name <input type="text" name="userName" >
<input type="submit" value="submit">
</form>
最後的web.xml:
<servlet>
<servlet-name>check</servlet-name>
<display-name>check</display-name>
<description></description>
<servlet-class>MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>check</servlet-name>
<url-pattern>/check</url-pattern>
</servlet-mapping>
問題在於參數呃不會傳遞給welcome.jsp。我仍然看到
$ USERNAME
問題是什麼?請幫幫我。