zoukankan      html  css  js  c++  java
  • 【JSTL】--读取实体成员变量吗?--drp212

    User.java

    /**
     * 
     */
    package com.bjpowrnode.jstl;
    
    /**
     * @ClassName:User
     * @Description:TODO
     * @author wm
     * @date 2016年2月15日上午9:42:15
     */
    public class User {
    
    	private String username1;
    	private  int  age;
    	private Group group;
    	public String getUsername() {
    		return username1;
    	}
    	public void setUsername(String username1) {
    		this.username1 = username1;
    	}
    	public int getAge() {
    		return age;
    	}
    	public void setAge(int age) {
    		this.age = age;
    	}
    	public Group getGroup() {
    		return group;
    	}
    	public void setGroup(Group group) {
    		this.group = group;
    	}
    
    }
    

    JSP

    <%@ page language="java" contentType="text/html; charset=GB18030"
        pageEncoding="GB18030"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GB18030">
    <title>Insert title here</title>
    </head>
    <body>
    	<h1>测试EL表达式</h1>
    	<hr>
    	<li>普通字符串</li><br>
    	hello(jsp脚本):<%=request.getAttribute("hello") %></br>
    	hello(El表达式:语法:$和{}:${hello}<br>
    	hello(el表达式,el内置对象,	pageScope,requestScope,sessionScope,applicationScope	)<br>
    	如果不指定范围,它的搜索范围就是pageScope~applicationScope():${requestScope.hello}<br>
    	hello(el表达式,从session中取得):${sessionScope.hello}<br>
    	
    	<p>
    	<li>结构</li>
    	姓名:${user.username}<br>
    	年龄:${user.age }<br>
    	所属:<br>
    </body>
    </html>
    

    username可以读取到结果,读取的时候,读取的是getUsername,而不是成员变量。

    先读取getUsername,然后取get后面的单词,小写。

  • 相关阅读:
    linux下mysql命令大全
    Linux 随记
    Linux服务器部署系列之八—Sendmail篇
    Linux服务器部署系列之六—远程管理篇
    ubuntu简易教程(如何使用noi linux)
    51nod1254 最大子段和 V2 DP
    [HAOI2007]理想的正方形 st表 || 单调队列
    [LG1886]滑动窗口 单调队列
    [51nod1791] 合法括号子段 DP
    [51nod1503]猪和回文 DP
  • 原文地址:https://www.cnblogs.com/wangmei/p/5190045.html
Copyright © 2011-2022 走看看