<bean:define>标签用于定义一个变量.id属性指定变量的名字,toScope属性指定变量存放范围,如果没有设置toScope属性,则变量存放在page范围内.
给id属性定义变量赋值方式:
1.设置value属性,此时id属性定义的变量为字符串(String)类型,value属性代表这个变量的字符串值.
<bean:define id="str" value="Hello MLDN...."></bean:define>
可以通过jsp的EL语言${str}来取得或者><bean:write name="str"></bean:write>来取得值
2.同时设定name和property属性.name属性指定一个已经存在的bean,property属性指定已经存在的bean中的某个属性,id属性定义的变量值由property属性决定:
<%request.setAttribute("sessionBean",session);%>
<bean:define id="contextBean" name="sessionBean" property="servletContext"/>
Servlet Context name:<bean:write name="contextBean" property="servletContextName"/>
例:建立一个jsp页面:
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<html:html lang="true">
<head>
<title>beanDefine.jsp</title>
</head>
<body>
<!-- bean:define作用
定义或复制一个对象
1.定义对象一般为String类型
2.复制对象->迭代标签 -->
<!-- 下面为定义一个对象 -->
<bean:define id="str" value="Hello MLDN...."></bean:define>
<!-- 两种输出方法
id就表示一个存放在四种属性范围之中的名称
name表示使用一个存放在四种属性范围中的对象-->
<h1>${str }</h1>
<!--bean:write 用于打印输出
使用对象时用name属性 -->
<h1><bean:write name="str"></bean:write></h1>
</body>
</html:html>
|
分享到:
相关推荐
bean:define 3 bean:header 4 bean:include 5 bean:message 5 bean:page 7 bean:parameter 7 bean:resource 8 bean:size 8 bean:struts 9 bean:write 9 html:base 10 html:cancel 11 html:select 12 ...
1. Map里存放的是bean时 <br><logic:iterate id="destMap" name="srcMap"> <br> <bean:define id="bean" name="destMap" property="value" /> <br> <bean:write name="bean" property="name" /> <br>...
<bean:define id=”test” value=”this is a test”/> 源bean在页作用域中被拷贝大哦请求作用域中的另一个bean: <bean:define id=”targetBean” name=”sourceBean” scope=”page” toScope=”request”/>
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>标签 16.4.6、<html:hidden...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>标签 16.4.6、<html:hidden...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<...
4.4.3 ui:define 4.4.4 ui:insert 4.4.5 ui:include 4.4.6 ui:param 4.5 facelets非模板化标签使用指南 4.5.1 ui:component 4.5.2 ui:fragment 4.5.3 ui:remove 4.5.4 ui:debug 第5章 托管bean与JSF表达式语言 5.1 ...
4.4.3 ui:define 4.4.4 ui:insert 4.4.5 ui:include 4.4.6 ui:param 4.5 facelets非模板化标签使用指南 4.5.1 ui:component 4.5.2 ui:fragment 4.5.3 ui:remove 4.5.4 ui:debug 第5章 托管bean与JSF表达式语言 5.1 ...
But you can define some interceptors in a totally different class, and link them with any controller using the @With annotation.由于java不允许多继承,通过控制器继承特点来应用拦截器就受到极大的限制。...
But you can define some interceptors in a totally different class, and link them with any controller using the @With annotation.由于java不允许多继承,通过控制器继承特点来应用拦截器就受到极大的限制。...