0
我有一个.JSP形式,像这样Struts2的表单提交不打方法
<s:form action="AuditLogReport">Source IP<br>
<input type="text" class="auditLogSearch" name="sourceIp" value="All">
<input type="submit" value="Submit"/>
</s:form>
而我在struts.xml定义
<action name="AuditLogReport"
class="com.mycom.selfservice.actions.AuditLogAction" method="auditLogReport">
<result name="success">jsp/AuditLog.jsp</result>
<result name="error">jsp/Error.jsp</result>
</action>
这里是我的类定义
public class AuditLogAction extends ActionSupport implements Action,ServletRequestAware {
在我的AuditLogAction类中有一个方法
public String auditLogReport() {
System.out.println("Im in auditLogReport...");
但是当我点击按钮时,auditLogReport方法不会被击中。我在浏览器url中看到的是http://localhost:7001/BPSelfServicePortal/AuditLogReport.action
这是追加.action,我认为它是为什么它找不到方法。所以我试图在struts.xml中把
<constant name="struts.action.extension" value=""/>
。这阻止了.action被添加,但按钮仍然无效。另外它会导致找到.css和图像。我有一个使用默认execute()方法的链接,并且工作正常。
如果我只是删除url中的.action,然后回车,它会触发该方法,但是表单中的值都不会被传递。
对此提出建议?