我会尽量具体。
我有一个具有两种方法的操作,一种是通过 ajax 调用,另一种是通过常规提交调用。
关键是无法从常规提交中获取请求,我只获取操作属性。
public class ClientAction{
@SMDMethod
public Map<String, Object> findClient(String myParam){
...
}
public String saveClient(){
Map<String, String[]> parameterMap = this.getRequest().getParameterMap();
}
}
来自 saveClient 方法的 getRequest 返回 null !!!但为什么???我没有用@SMDMethod 声明它
这是struts.xml
<action name="client" class="myCompany.ClientAction">
<interceptor-ref name="customJSON"><param name="enableSMD">true</param></interceptor-ref>
<result type="json"><param name="enableSMD">true</param></result>
</action>
我做了所有其他的声明。我曾经有两个单独的类,每个方法一个,但是使用 ClientAction 和 ClientActionJSON 可维护性并不容易。
关于如何在同一个类中同时拥有两种方法的任何想法,一种是ajax,另一种不是。