详细内容
使用转发来给jsp页面赋值。具体操作如下:
这个在servlet中可是使用转发实现参数传递protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
request.setAttribute("username", "dhweicheng");
request.setAttribute("password", "123456");
request.getRequestDispatcher("/my.jsp").forward(request, response);
}
jsp页面代码:
pageEncoding="UTF-8"%>
页面代码通过request对象取值
账号:
密码:
=======================
通过EL表达式取值
账号:${username}
密码:${password}