How to connect an action using the HTML <a href= ""/> Tag

Source: Internet
Author: User

<a href= "<s:url action=" blogList "/>" >XXXX</a>

A simpler notation is

<a href= "blogdelete.action?id=xxx" > Just write it.

If this action is declared in struts, there is a namespace such as/user

So write <a href= "User/blogdelete.action?id=xxx" >

When using the STRUTS2 action tag, you can call action directly on the JSP page, and when you call action, you can specify the name and namespace of the action, if the property value of the Executeresult parameter is true, The label will then include the action's processing results (that is, view resources) on this page. The s:action tag specifies that the properties are:

ID: Optional attribute, as the app ID for the action

Name: Required property, specifying the action name to invoke

namespace: Optional attribute that specifies that the label calls the namespace to which the action belongs

Executeresult: Optional attribute that specifies whether the action's processing results are included in this page. Default value is False (not included)

Ignorecontextparam: Optional parameter that specifies whether the request parameter for the page requires an in-call action, and the default value is False, which is the passed-in parameter

Example: index.jsp main code

[HTML]View Plaincopy
  1. < %@ Page language = "Java" Import="java.util.*" pageencoding=" Iso-8859-1 "%>
  2. < % @taglib prefix = "S" uri="/struts-tags"%>
  3. < %  
  4. String path = request. Getcontextpath ();
  5. String basepath = request. Getscheme () + "://" +request.getservername () + ":" +  Request.getserverport () +path+ "/";
  6. %>
  7. <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en">
  8. < HTML >   
  9. < Head >   
  10. < Base href="<%=basePath%>">
  11. < title > Struts2 a:action </ title >   
  12. </ Head >   
  13. < Body >   
  14. < Div >   
  15. < s:action name="modle_show" namespace="/ Webs " executeresult=" true ">
  16. < S:param name="name" value=' 1 '>   
  17. </ S:param >   
  18. </ s:action >    
  19. </ Div >   
  20. </ Body >   
  21. </ HTML >   


test.jsp Main code

[HTML]View Plaincopy
  1. < %@ Page ContentType = "text/html; Charset=utf-8 " language=" java "%>
  2. < % @taglib URI = "/struts-tags" prefix="s"%>
  3. < S:property  value="Content" escape="false" />


Struts.xml's action code:

[Java]View Plaincopy
    1. <action name= "Modle_*" class="modleaction" method="{1}" >
    2. <result name="test">/webs/content.jsp</result>
    3. </action>


This aciton is executed on the page when the index.jsp is accessed, and the final result page (that is, all the results pages on test.jsp) is included in the index.jsp

How to connect an action using the HTML <a href= ""/> Tag

How to connect an action using the HTML <a href= ""/> Tag

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.