在我的项目中,我正在使用双选框,但在运行操作时,它显示以下异常。我尝试过如下:java.lang.IllegalStateException: getInputStream() has already been called for this request + Struts2 and JSON但收到同样的异常。我不知道如何继续下去。
Stacktrace:
java.lang.AbstractMethodError: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.getClientInfo()Ljava/util/Properties;
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:225)
$Proxy5.getClientInfo(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:227)
org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
org.apache.struts2.json.JSONWriter.write(JSONWriter.java:99)
org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:112)
org.apache.struts2.json.JSONResult.execute(JSONResult.java:198)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
我的struts.xml
有以下内容:
<action name="fetchlocation" class="com.tcs.mhealth.chlorotester.actions.FetchLocationAction">
<interceptor-ref name="basicStack" />
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="json">
<param name="enableSMD">false</param>
</interceptor-ref>
<result type="json" name="success">
<param name="enableSMD">false</param>
<param name="root"></param>
</result>
</action>
答案 0 :(得分:0)
执行JSON结果时,root
对象的所有属性都被序列化为JSON。但是你将root
参数留空了。即使struts.xml
的验证失败,文档仍然会被解析而没有错误,但它有一个警告
WARN (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider:56) - no default parameter defined for result of type json
当默认参数root
为空时,序列化对象将从值堆栈中查找。在大多数情况下,它是一个动作bean。但在您的情况下,您不应该序列化此bean,因为它可能包含应从序列化中排除的属性,例如数据源属性。
要从JSON对象填充选择框,您应该只序列化包含列表值的属性。如果将此属性名称用作root
参数值,则可以执行此操作。如果需要为双精度框序列化两个列表,则可以将root
对象保留为默认值并使用JSON结果的includeProperties
参数,并将两个列表属性与结果一起放置。
Including properties
可以将以逗号分隔的正则表达式列表传递给 JSON结果限制将序列化哪些属性。只要 将包含与任何这些正则表达式匹配的属性 在序列化输出中。
注意
排除属性表达式优先于include属性 表达式。也就是说,如果使用include和exclude属性 表达式在相同的结果上,include属性表达式不会 如果排除排除属性表达式与a匹配,则应用 物业第一。
<!-- Result fragment --> <result type="json"> <param name="includeProperties"> ^entries\[\d+\]\.clientNumber, ^entries\[\d+\]\.scheduleNumber, ^entries\[\d+\]\.createUserId </param> </result>
此外,它没有关系,但是如果你用拦截器覆盖一个动作配置,看看每个堆栈包含哪些拦截器,并且不需要重复相同的拦截器两次。在您的情况下,应使用基本或默认堆栈。