bean标签的使用
bean:write
bean:message
该标签通常和资源配置文件ApplicationResources.properties使
用,可以更加方便的输出信息
<%@ page language="java"
import="java.util.*,com.xing.domain.*"
pageEncoding="utf-8"%>
<%@ taglib prefix="bean"
uri="http://struts.apache.org/tags-bean" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">
<html>
<head>
<title>My JSP 'bean.jsp' starting page</title>
</head>
<body>
<%request.setAttribute("abc","Hello,World!");
User u=new User();
u.setName("xiaoming");
u.setAge(3);
request.setAttribute("user1",u);
%>
<h2>bean table use</h2>
<p>输出文本</p>
<bean:write name="abc"/>
<p>输出对象的属性值</p>
<bean:define id="kkkk" name="abc" value="hello"
scope="request" property="name"></bean:define>
<bean:write name="user1" property="name"/>
<bean:write name="user1" property="age"/><br/>
<p>bean:message</p>
<bean:message key="key1" arg0="Tomson"/>
<bean:message key="err1" arg0="用户名为空" />
<p>jsp:useBean 的用法</p>
<jsp:useBean id="user2"
class="com.xing.domain.User"></jsp:useBean>
<jsp:setProperty name="user2" value="xiaohua"
property="name"/>
<jsp:setProperty name="user2" value="32"
property="age"/>
&{user2.name}
<% User user3=new User();
user3.setName("xiaohua");
user3.setAge(23);
%>
</body>
</html>
为什么不支持el表达式?
logic标签的使用
类似jstl c:forEach
<logic:iterate id="pName" name="user">
<bean:write name="pName" property="name"/>
<bean:write name="pName" property="age"/>
${pName.name}
${pName.age}
</logic:itrate>
jstl和struts标签的使用建议
jstl->el->struts