在jsp页面使用el表达式获取javaBean属性值


JavaBean类

package entity;

public class Student {

	private boolean flag;//是否接受协议
	
	public Student(){}

	public boolean getFlag() {
		return flag;
	}
	public void setFlag(boolean flag) {
		this.flag = flag;
	}
	
}


Servlet类

public class StudentServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Student student = new Student();
		student.setFlag(false);
		
		request.setAttribute("student", student);
		request.getRequestDispatcher("student.jsp").forward(request, response);
	}

}


jsp页面


使用EL表达式获取JAVABEAN的属性值

${student.flag}


使用:

是否接受协议:


如果student类中有List类型的属性list,在Jsp页面中遍历


    
        ${obj}

如果student类中有Map类型的属性map,在Jsp页面中遍历


    
        ${obj.key}




你可能感兴趣的:(在jsp页面使用el表达式获取javaBean属性值)