<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
- < %@ Page language = "Java" Import="java.util.*" pageencoding=" Iso-8859-1 "%>
- < % @taglib prefix = "S" uri="/struts-tags"%>
- < %
- String path = request. Getcontextpath ();
- String basepath = request. Getscheme () + "://" +request.getservername () + ":" + Request.getserverport () +path+ "/";
- %>
- <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en">
- < HTML >
- < Head >
- < Base href="<%=basePath%>">
- < title > Struts2 a:action </ title >
- </ Head >
- < Body >
- < Div >
- < s:action name="modle_show" namespace="/ Webs " executeresult=" true ">
- < S:param name="name" value=' 1 '>
- </ S:param >
- </ s:action >
- </ Div >
- </ Body >
- </ HTML >
test.jsp Main code
[HTML]View Plaincopy
- < %@ Page ContentType = "text/html; Charset=utf-8 " language=" java "%>
- < % @taglib URI = "/struts-tags" prefix="s"%>
- < S:property value="Content" escape="false" />
Struts.xml's action code:
[Java]View Plaincopy
- <action name= "Modle_*" class="modleaction" method="{1}" >
- <result name="test">/webs/content.jsp</result>
- </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