- 浏览: 55311 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
892870119:
这么基础的问题,我怎么不知道,查了半天,唉~~~~
Struts s:if 标签 判断中文 -
wnjustdoit:
给力。。。。
struts.xml向页面传参 -
summer_021:
wkshippou 写道汗!怎么去添加web应用的时候不要加上 ...
EE5 jar 冲突解决办法 -
wkshippou:
汗!怎么去
EE5 jar 冲突解决办法
bean标签:
Action:
页面显示:
配置文件:
使用struts1 bean:write标签必须提供一份国际化文件: MessageResources
否则会报:
Cannot find message resources under key org.apache.struts.action.MESSAGE
在src下面提供一份文件即可 内容为空也可以
使用bean标签需要在页面中加入:
logic标签:
Action:
页面使用标签:
Iterate标签:
页面显示:
使用Iterate标签加上:
Action:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // 普通属性 request.setAttribute("hello", "Hello World"); // html文本 request.setAttribute("hz", "<font color='red'>杭州欢迎您</font>"); // 日期 request.setAttribute("today", new Date()); // 数字 request.setAttribute("n", 123456.987); // 结构 Group group = new Group(); group.setName("和盈"); User user = new User(); user.setUsername("张三"); user.setAge(18); user.setGroup(group); request.setAttribute("user", user); return mapping.findForward("success"); }
页面显示:
<h1>测试BeanWrite</h1> <hr> <li>普通字符串</li><br> hello(jsp脚本):<%=request.getAttribute("hello") %><br> hello(标签):<bean:write name="hello"/><br> <p> <li>html文本</li><br> hz(default):<bean:write name="hz"/><br> hz(filter="true"):<bean:write name="hz" filter="true"/><br> hz(filter="false"):<bean:write name="hz" filter="false"/><br> <p> <li>格式化日期</li><br> today(default):<bean:write name="today"/><br> today(format="yyyy-MM-dd HH:mm:ss"):<bean:write name="today" format="yyyy-MM-dd HH:mm:ss"/> <p> <li>格式化数字</li><br> n(default):<bean:write name="n"/><br> n(format="###,###.####"):<bean:write name="n" format="###,###.####"/><br> n(format="###,###.####"):<bean:write name="n" format="###,###.0000"/><br> <p> <li>结构</li><br> 姓名:<input type="text" value="<bean:write name="user" property="username"/>"><br> 年龄:<input type="text" value="<bean:write name="user" property="age"/>"><br> 所属组:<input type="text" value="<bean:write name="user" property="group.name"/>"><br> </body>
配置文件:
<action-mappings> <action path="/beanwrite" type="com.aowin.struts.BeanWriteTestAction"> <forward name="success" path="/beanwrite.jsp" /> </action> <action path="/emptypresent" type="com.aowin.struts.EmptyPresentTestAction"> <forward name="success" path="/emptypresent.jsp" /> </action> <action path="/iterate" type="com.aowin.struts.IterateTestAction"> <forward name="success" path="/iterate.jsp" /> </action> </action-mappings> <message-resources parameter="MessageResources" />
使用struts1 bean:write标签必须提供一份国际化文件: MessageResources
否则会报:
Cannot find message resources under key org.apache.struts.action.MESSAGE
在src下面提供一份文件即可 内容为空也可以
使用bean标签需要在页面中加入:
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean"%>
logic标签:
Action:
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute("attr1", null); request.setAttribute("attr2", ""); request.setAttribute("attr3", new ArrayList()); return mapping.findForward("success"); }
页面使用标签:
<h1>测试empty,notEmpty,present,notPresent</h1> <hr> <logic:empty name="attr1"> attr1为空<br> </logic:empty> <logic:notEmpty name="attr1"> attr1不为空<br> </logic:notEmpty> <logic:present name="attr1"> attr1存在<br> </logic:present> <logic:notPresent name="attr1"> attr1不存在<br> </logic:notPresent> <p> <logic:empty name="attr2"> attr2为空<br> </logic:empty> <logic:notEmpty name="attr2"> attr2不为空<br> </logic:notEmpty> <logic:present name="attr2"> attr2存在<br> </logic:present> <logic:notPresent name="attr2"> attr2不存在<br> </logic:notPresent> <p> <logic:empty name="attr3"> attr3为空<br> </logic:empty> <logic:notEmpty name="attr3"> attr3不为空<br> </logic:notEmpty> <logic:present name="attr3"> attr3存在<br> </logic:present> <logic:notPresent name="attr3"> attr3不存在<br> </logic:notPresent>
Iterate标签:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Group group = new Group(); group.setName("和盈"); List userList = new ArrayList(); for (int i=0; i<10; i++) { User user = new User(); user.setUsername("user_" + i); user.setAge(18+i); user.setGroup(group); userList.add(user); } request.setAttribute("userlist", userList); return mapping.findForward("success"); }
页面显示:
<h1>测试Iterate</h1> <hr> <li>jsp脚本</li><br> <table border="1"> <tr> <td>姓名</td> <td>年龄</td> <td>所属组</td> </tr> <% List userList = (List)request.getAttribute("userlist"); if (userList == null || userList.size() == 0) { %> <tr> <td colspan="3">没有符合条件的数据!</td> </tr> <% }else { for (Iterator iter=userList.iterator(); iter.hasNext(); ) { User user = (User)iter.next(); %> <tr> <td><%=user.getUsername() %></td> <td><%=user.getAge() %></td> <td><%=user.getGroup().getName() %></td> </tr> <% } } %> </table> <p> <li>标签</li><br> <table border="1"> <tr> <td>姓名</td> <td>年龄</td> <td>所属组</td> </tr> <logic:empty name="userlist"> <tr> <td colspan="3">没有符合条件的数据!</td> </tr> </logic:empty> <logic:notEmpty name="userlist"> <logic:iterate id="u" name="userlist"> <tr> <td> <bean:write name="u" property="username"/> </td> <td> <bean:write name="u" property="age"/> </td> <td> <bean:write name="u" property="group.name"/> </td> </tr> </logic:iterate> </logic:notEmpty> </table>
使用Iterate标签加上:
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean"%> <%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic"%>
发表评论
-
Struts1_处理数据的技巧
2012-05-31 21:15 9131、ActionFrom中:productId ... -
Struts1_学习笔记7_struts0600_actionforward_重定向_actionforward_actionmapping
2012-05-30 13:56 2367ActionForward的使用 1、重定向: 第一种实现方 ... -
Struts1_学习笔记6_struts0500_actionform_动态ActionForm_转换器
2012-05-30 13:38 10591、动态ActionForm 动 ... -
Struts1中的struts-config.xml配置文件_转
2012-05-30 12:29 818以下内容是否都正确 不 ... -
Struts1_学习笔记5_struts0400_jstl_格式化库_函数库
2012-05-29 14:49 986jstl标签库的配置 * 将jstl.jar和standar ... -
Struts1_学习笔记4_struts0400_jstl_EL表达式_核心库
2012-05-28 21:34 11591、使用JSTL,Servlet最低版本:2.4,查看Serv ... -
Struts1_学习笔记2_struts0200_trainnig_cal
2012-05-28 20:29 621Action: @Override public Ac ... -
Struts1_学习笔记1_struts0100_login
2012-05-28 20:23 839Action:单实例(单例),多线程使用时如果有可以修改的成员 ... -
不用Struts2标签 拿到OGNL值栈的值_转
2012-05-24 16:10 676首先WEBWORK的核心机制是OGNL,于是追了一下有关XWO ... -
(转) Struts2 URL参数 s:if 判断应用
2012-05-04 10:14 692Struts2的s:if标签很怪异,下面来具体地看看,如何用s ... -
Struts2 xml 配置 常量 action_转
2011-08-04 09:50 965<?xml version="1. ... -
Struts2 Iterator 标签
2011-07-05 10:12 792struts2的s:iterator 可以遍历 数据栈里面的任 ... -
Struts 去FieldErrror红点
2011-06-09 17:18 696<style type="text/css&q ... -
Struts s:if 标签 判断中文
2011-06-09 09:54 2608username 来自action 在页面上取得usern ... -
struts.xml向页面传参
2011-06-08 20:54 1895请求地址: <a href="actio ...
相关推荐
Struts2_03Taglib : Struts2常用标签的使用方法 Struts2默认支持OGNL、JSTL、Groovy和Velcity表达式 Struts2_04ActionResultType : Struts2关于Action跳转类型的应用 对各种不同的跳转类型使用的实例 Struts2_05...
我就是靠这个文档实现logic:iterate的循环的 struts 标签 logic:iterate使用 logic:iterate <br>第一页 是struts官方的说明, 第二页 是个例子 第三页 是我实现的arrayList放入标签的方法。 这是页面...
03 Struts_03Taglib : 演示Struct的标签库,html、bean、logic标签的用法 04 Struts_04DispatchAction : 分发Action,根据设置的参数值提交到不同的方法进行处理业务,演示数学运算 05 Struts_05DynaActionForm : 相...
绝对可以解决这个这个问题。Struts初学者绝对可以受用的方法。
struts2.0 taglib struts2.0 标签库,总结了从的全部
struts taglib使用示例 struts taglib使用示例 struts taglib使用示例struts taglib使用示例 struts taglib使用示例
taglib(struts2标签).doc
struts-taglib-1.3.10.jar struts-taglib.jar taglib.jar
struts-taglib-1.3.8.jar struts-taglib-1.3.8.jar
用过struts1.x的人都知道,标签库有html、bean、logic、tiles, 而struts2.0里的标签却没有分类,只用在jsp头文件加上 <%@ taglib prefix="s" uri="/struts-tags" %> 就能使用struts2.0的标签库
pager-taglib 安装包和使用手册。
<%@ taglib prefix="s" uri="/struts-tags" %> 就能使用struts2.0的标签库 下面就介绍每个标签的具体应用实例说明:按字母排列 A: 1. 2. <s:a href=""></s:a>-----超链接,类似于html里的<a></a> 3. ...
主要介绍了struts2的标签的详细使用例子说明
关于Struts Taglib的现实介绍
jsp使用自定义标签taglib分页系列——完整例子(其中struts控件和包我没有加入,需要自己加入)
Struts2中实现自定义标签很简单,主要分为3步: 1.创建taglib文件(.tld),编写标签声明。 2.编写自定义标签类。 3.在页面中使用标签。 下面以一个自定义的分页标签为例,进行说明。 其实,开发自定义标签并不...
用过struts1.x的人都知道,标签库有html、bean、logic、tiles, 而struts2.0里的标签却没有分类,只用在jsp头文件加上 <%@ taglib prefix="s" uri="/struts-tags" %> 就能使用struts2.0的标签库
struts标签中文文档 下载附件后把taglib1.war放在tomcat的webapps下,(或用其他应用服务器) 然后启动tomcat服务 在浏览器中输入http://localhost:8080/taglib1即可
struts2 标签 Taglib (Struts2标签库)