structs:关于使用超链接调用action的问题
这是structs.xml中的配置信息:
<package name="orders" namespace="/orders" extends="struts-default">
<!-- 传递要修改订单信息Action -->
<action name="PassOrdersInfoAction" class="cn.edu.xmu.nextgentb.eclipse.action.PassOrdersInfoAction">
<result name="success">../modifyOrdersSumForm.jsp</result>
</action>
</package>
这是JSP页面:
<title>您可以修改订单总额</title>
</head>
<body>
<table>
<thead>
<tr>
<td>订单编号</td>
<td>顾客编号</td>
<td>订单状态</td>
<td>订单总额</td>
<td>可进行的操作</td>
</tr>
</thead>
<!-- 循环遍历查询结果,并显示 -->
<s:iterator value="resultList">
<tr>
<td><s:property value="orderId"/></td>
<td><s:property value="customerId"/></td>
<td><s:property value="date"/></td>
<td><s:property value="state"/></td>
<td><s:property value="sum"/></td>
<td>
<s:url id="modify" action="PassOrdersInfoAction">
<s:param name="ordersinfo.orderId"><s:property value="orderId"/></s:param>
<s:param name="ordersinfo.state"><s:property value="state"/></s:param>
<s:param name="ordersinfo.date"><s:property value="date"/></s:param>
<s:param name="ordersinfo.isVisibleForS"><s:property value="isVisibleForS"/></s:param>
<s:param name="ordersinfo.isVisibleForC"><s:property value="isVisibleForC"/></s:param>
<s:param name="ordersinfo.customerId"><s:property value="customerId"/></s:param>
<s:param name="ordersinfo.storeId"><s:property value="storeId"/></s:param>
<s:param name="ordersinfo.consigneeId"><s:property value="consigneeId"/></s:param>
<s:param name="ordersinfo.shipping"><s:property value="shipping"/></s:param>
<s:param name="ordersinfo.insurance"><s:property value="insurance"/></s:param>
<s:param name="ordersinfo.promocode"><s:property value="promocode"/></s:param>
<s:param name="ordersinfo.sum"><s:property value="sum"/></s:param>
</s:url>
<s:a href="%{modify}">修改订单总金额</s:a>
</td>
</tr>
</s:iterator>
</table>
这是PassOrdersInfoAction:
package cn.edu.xmu.nextgentb.eclipse.action;
import com.opensymphony.xwork2.ActionSupport;
import cn.edu.xmu.nextgentb.eclipse.vo.Orders;
public class PassOrdersInfoAction extends ActionSupport{
Orders orderinfo=new Orders();
public Orders getOrdersinfo() {
return orderinfo;
}
public void setOrdersinfo(Orders orderinfo) {
this.orderinfo = orderinfo;
}
public String execute()throws Exception{
System.out.println("run here");
return SUCCESS;
}
}
问题:无论我将<s:url id="modify" action="PassOrdersInfoAction">改成<s:url id="modify" action="PassOrdersInfoAction">还是<s:url id="modify" action="/orders/PassOrdersInfoAction">系统都提示【There is no Action mapped for namespace [/orders] and action name [PassOrdersInfoAction] associated with context path [/struts2].
There is no Action mapped for namespace [/orders] and action name [PassOrdersInfoAction] associated with context path [/struts2]. - [unknown location]】
请问这个问题如何处理
[解决办法]
action="/orders/PassOrdersInfoAction"
这个路径如果你用绝对路径就要从项目明开始。
这里可以是相对路径