2获取值
1.el表达式只能从域对象中获取值
2语法:
1.$[域名称.键}:从指定域中获取指定键的值域名称:1.pageScope2.requestScope
3.sessionScope
4.applicationScope–>
举例:在 request 域中存储了 name =张三*获取:${ requestScope . name }
–> pageContext –> request
–> session
epplication ( ServletContext )
2.$[键}:表示依次从最小的域中查找是否有该键对应的值,直到找到为止。
<%
1/在域中存储数据
session . setAttribute (" name ","李四");
request . setAttribute (" name ", "张三");
session . setAttribute ("age ", "23");
%>
<h3> el 获取值</h3>
${ requestScope . name }
${ sessionScope . age }
${ sessionScope . haha }
${name }
${ sessionScope . name }
3获取对象、 List 集合、 Map 集合的值
1对象:$[域名称.键名属性名}
本质上会去调用对象的 getter 方法
${ requestScope . u . name }< br >
${ u . age }< br >
${ u . birthday }< br >
${ u . birthday . month }< br >
${ u . birtr }< br >
java代码
private String name ;
private int age ;
private Date birthday ;
public String getBirstr(){
if ( birthday !=nul1){
//1.格式化日期对象
SimpleDateFormat sdf = new SimpleDateFormat ( pattern :"уууу- MM - dd HH : mm : ss ");
//2.返回字符串即可
return sdf . format (Ь irthday );
} else {
return "";
}
下面的是get set方法
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/282984.html