您好,欢迎来到易妖游戏网。
搜索
您的当前位置:首页Struts2 数据 标签 之 Action Tag

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

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- vipyiyao.com 版权所有 湘ICP备2023022495号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务