Struts2 数据 标签 之 Action Tag
2011-06-13 14:05
316 查看
Action Tag
The action tag is a generic tag that is used to call actions directly from a JSP page by specifying the action name and an optional namespace. The body content of the tag is used to render the results from the Action. Any result processor defined for this action in struts.xml will be ignored, unless the executeResult parameter is specified.
Add the following code snippet into the struts.xml file.
struts.xml
Create an action class as shown below:
actionTag.java
Now create a jsp page using
success.jsp
Output of the success.jsp
The action tag is a generic tag that is used to call actions directly from a JSP page by specifying the action name and an optional namespace. The body content of the tag is used to render the results from the Action. Any result processor defined for this action in struts.xml will be ignored, unless the executeResult parameter is specified.
Add the following code snippet into the struts.xml file.
struts.xml
<action name="actionTag" class="net.roseindia.actionTag"> <result name="success">/pages/genericTags/success.jsp</result> </action> |
actionTag.java
package net.roseindia; import com.opensymphony.xwork2.ActionSupport; public class actionTag extends ActionSupport { public String execute() throws Exception{ return SUCCESS; } } |
<s:action
>tag as shown in the success.jsppage. The action tag is used to call actions directly from a JSP page by specifying the action name and an optional namespace.
success.jsp
<%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <title>Action Tag Example!</title> </head> <body> <h1><span style="background-color: #FFFFcc">Action Tag (Data Tags) Example!</span></h1> <s:action name="success"> <b><i>The action tag will execute the result and include it in this page.</i></b></div> </s:action> </body> </html> |
相关文章推荐
- Struts 2的标签库(3)——数据标签
- struts OGNL数据标签
- 在Struts中使用displaytag标签的排序/分页数据
- struts标签三种方法得到查询数据的条数
- 通过Struts标签和JSTL标签来遍历List<Map<String,String>>格式的数据
- 在Struts标签中对数据的几种遍历
- 在Action中查询出SQL SERVER表的数据,返回一个list。怎么在JSP页面中使用Struts标签,显示出表中的内容?(转)
- struts1.x 后台读取数据至html:select标签方法
- 页面上通过struts标签获取javabean里的数据(s:property)
- 处理乱码及通过Struts标签显示数据
- Struts2 数据 标签 之 Bean Tag
- 【Hibernate】把Hibernate在后台查询到的数据通过Struts标签在前台进行输出
- jsp struts标签迭代各种数据
- Struts2 数据 标签 之 Date Tag
- 【Struts2六】ui标签之form标签及数据回显
- Struts2 数据 标签 之 Include Tag
- Struts2 数据 标签 之 Text Tag
- Struts2 数据 标签 之 Property Tag
- 7.Struts采用EL保持表单数据:改成用struts的html标签保持数据
- struts标签iterator遍历非属性数据