Java Struts2+;Spring:请求参数在动作对象中不重置?

Java Struts2+;Spring:请求参数在动作对象中不重置?,java,spring,struts2,httprequest,Java,Spring,Struts2,Httprequest,我正在开发Spring 3+Struts2应用程序,我在Spring中的操作配置如下: <bean id="patientSearchAPIClass" class="com.axiohelix.nozoki.web.action.api.PatientSearch"> <property name="searchService" ref="searchService"/> </bean> 此操作返回JS

我正在开发Spring 3+Struts2应用程序,我在Spring中的操作配置如下:

  <bean id="patientSearchAPIClass" class="com.axiohelix.nozoki.web.action.api.PatientSearch">     
       <property name="searchService" ref="searchService"/>        
    </bean> 
此操作返回JSON输出,我使用URL访问它,如:

http://localhost/app/searchAPI.action?name=UserName

下一次如果我使用URL访问:

http://localhost/app/searchAPI.action

字段“name”设置为以前的“UserName”值

1.如何根据请求重置这些值


2.我以为每个请求都会实例化动作类,不是吗?

问题在于Spring创建动作类的方式。默认情况下,Spring创建单例实例,而对于Struts2,动作类也可以作为模型使用,因为这个框架创建了一个新的动作实例,并将其放在值堆栈中

在使用Spring创建action类时,请确保像prototype一样定义范围

<bean id="patientSearchAPIClass" 
 class="com.axiohelix.nozoki.web.action.api.PatientSearch" scope=prototype>


因此,Spring应该为每个请求创建新的操作实例。

您是否使用struts2 Spring插件如果是,请将bean范围更改为
prototype
,因为默认情况下,它的singleton和S2也将操作用作数据传输对象。如
是,我正在使用struct2 spring插件。谢谢你的提示。让我试试。@Umeshawashi感谢它起了作用。你能把这个作为一个答案发布出来,这样我就可以选择它是正确的。@Stevenbeintez:是的,我同意,我在使用spring的时候看到很多人甚至有相同的问题,我正在用spring维护Struts项目。老实说,我讨厌Struts,因为
Action
必须使用
prototype
范围进行声明。
<bean id="patientSearchAPIClass" 
 class="com.axiohelix.nozoki.web.action.api.PatientSearch" scope=prototype>