Struts2 数据 标签 之 Action Tag

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

<action name="actionTag" class="net.roseindia.actionTag">
   <result name="success">/pages/genericTags/success.jsp</result>
</action>

 

 

Create an action class as shown below:

actionTag.java

package net.roseindia;
import com.opensymphony.xwork2.ActionSupport;

public class actionTag extends ActionSupport {
  public String execute() throws Exception{
  return SUCCESS;
  }
}

 

 

Now create a jsp page using <s:action> tag as shown in the success.jsp page. 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 TagsExample!</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>

 

 

Output of the success.jsp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值