struts2拦截器问题

发布于 2024-09-11 10:39:56 字数 3765 浏览 2 评论 0原文

我是struts2的新手,在此之前我一直在使用struts1.2、Spring和Hibernate的组合。我刚刚开始使用 Struts2、Spring 和 Hibernate 应用程序,但我似乎受到拦截器异常的困扰,

有两个错误不断发生,都在不同的场景中

1) 2010-07-26 19:50:58,031 错误 org.apache.struts2.dispatcher.Dispatcher.error:27 - 找不到操作或结果 没有为操作 com.inrev.bm.action.IRCampaignMgmtAction 和结果输入定义结果 在 com.opensymphony.xwork2.DefaultActionInspiration.executeResult(DefaultActionInspiration.java:364) 在 com.opensymphony.xwork2.DefaultActionInspiration.invoke(DefaultActionInitation.java:266) 在 com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) 在org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) 在 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) 在 com.opensymphony.xwork2.DefaultActionInspiration.invoke(DefaultActionInspiration.java:237) 在 com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) 在 com.opensymphony.xwork2.DefaultActionInspiration.invoke(DefaultActionInspiration.java:237) 在 com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) 在 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) 在 com.opensymphony.xwork2.DefaultActionInspiration.invoke(DefaultActionInspiration.java:237) 在 com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)

2) 2010-07-26 22:09:22,779 DEBUG com.opensymphony.xwork2.interceptor.ParametersInterceptor.debug:57 - 设置参数会话 => [ {“session_key”:“djshjhdfkjhdjhuhhhgfhg-1133902930”,“uid”:1133902930,“过期”:0,“秘密”:“fjhfhlkasjdhfkdsjfhjhyhfhdjhfjkdh”,“sig”:“hfjdfhljksdfhj kasdhfjhdfjhakfjnmx,nvds"}] 2010-07-26 22:09:22,780 调试 com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - 属性:会话 2010-07-26 22:09:22,781 调试 com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - 类:com.inrev.bm.action.IRFacebookAction 2010-07-26 22:09:22,797 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - 属性会话的转换器为空。映射大小:0 2010-07-26 22:09:22,797 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - 属性 [session] = 未找到的字段级类型转换器 2010-07-26 22:09:22,798 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - 属性 [session] = 未找到的全局级类型转换器 2010-07-26 22:09:22,799 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - 回退到默认类型转换器 [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@18a62f6] 2010-07-26 22:09:22,804 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:61 - 无法使用类型转换器转换值 [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter] 无法从值 {"session_key":"6e2ecfba81fc0e9b889a80021133902930","uid":1133902930,"expires":0,"secret":" fjhfhlkasjdhfkdsjfhjhyhfhdjhfjkd","sig":"fe4 创建类型接口 java.util.Map 55338f9d869e589939d9c8dcdccb7"} - [未知位置]位于 com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:141) 在 com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:135) 在 com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue(XWorkConverter.java:323) 在 com.opensymphony.xwork2.ognl.OgnlTypeConverterWrapper.convertValue(OgnlTypeConverterWrapper.java:28) 在 ognl.OgnlRuntime.getConvertedType(OgnlRuntime.java:1040) 在 ognl.OgnlRuntime.getConvertedTypes(OgnlRuntime.java:1057) 在 ognl.OgnlRuntime.getConvertedMethodAndArgs(OgnlRuntime.java:1083)

我可以看出第一个错误与 Validator 拦截器相关,第二个错误与参数转换器相关,但我似乎不知道如何修复它们。在第二个例外中,所有参数值均从 facebook 发送。非常感谢您的帮助。

问候, 罗希特

I am new to struts2, prior to this I have been using struts1.2, Spring and Hibernate combination. I have just started using Struts2,Spring and Hibernate application, but I seem to be plagued with interceptor exceptions,

There are two error which keep happening, all in different scenarios

1) 2010-07-26 19:50:58,031 ERROR org.apache.struts2.dispatcher.Dispatcher.error:27 - Could not find action or result
No result defined for action com.inrev.bm.action.IRCampaignMgmtAction and result input
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:364)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)

2) 2010-07-26 22:09:22,779 DEBUG com.opensymphony.xwork2.interceptor.ParametersInterceptor.debug:57 - Setting params session => [ {"session_key":"djshjhdfkjhdjhuhhhgfhg-1133902930","uid":1133902930,"expires":0,"secret":"fjhfhlkasjdhfkdsjfhjhyhfhdjhfjkdh","sig":"hfjdfhljksdfhjkasdhfjhdfjhakfjnmx,nvds"} ]
2010-07-26 22:09:22,780 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: session
2010-07-26 22:09:22,781 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.inrev.bm.action.IRFacebookAction
2010-07-26 22:09:22,797 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - converter is null for property session. Mapping size: 0
2010-07-26 22:09:22,797 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - field-level type converter for property [session] = none found
2010-07-26 22:09:22,798 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - global-level type converter for property [session] = none found
2010-07-26 22:09:22,799 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@18a62f6]
2010-07-26 22:09:22,804 DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:61 - unable to convert value using type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
Cannot create type interface java.util.Map from value {"session_key":"6e2ecfba81fc0e9b889a80021133902930","uid":1133902930,"expires":0,"secret":" fjhfhlkasjdhfkdsjfhjhyhfhdjhfjkd","sig":"fe455338f9d869e589939d9c8dcdccb7"} - [unknown location] at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:141)
at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:135)
at com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue(XWorkConverter.java:323)
at com.opensymphony.xwork2.ognl.OgnlTypeConverterWrapper.convertValue(OgnlTypeConverterWrapper.java:28)
at ognl.OgnlRuntime.getConvertedType(OgnlRuntime.java:1040)
at ognl.OgnlRuntime.getConvertedTypes(OgnlRuntime.java:1057)
at ognl.OgnlRuntime.getConvertedMethodAndArgs(OgnlRuntime.java:1083)

I can make out that the first error is related to Validator interceptor and the second one is related to Parameter convertor, but I cannot seem to figure out how I can fix them. In the second exception all the parameter values are being sent from facebook. Help would be highly appreciated.

Regards,
Rohit

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…楫夜泊 2024-09-18 10:39:56

我可以帮助你解决第一个例外。您需要确保 com.inrev.bm.action.IRCampaignMgmtAction 的操作映射具有 input 结果:

 <action name="your-action-name" class="com.inrev.bm.action.IRCampaignMgmtAction">
   <result name="input">/WEB-INF/pat/to/input.jsp</result>
   <result name="success">/WEB-INF/pat/to/success.jsp</result>
 </action> 

更新

对于第二个错误,您可以在 XWorkConverter.getConverter() 方法(从第 366 行开始)。您的 com.inrev.bm.action.IRFacebookAction 类中的 session 属性是什么 Java 类型?

您可能必须定义自定义类型转换器 如果 XWork 默认情况下无法处理这种情况,请处理此情况。

I can help you with the first exception. You need to make sure your action mapping for com.inrev.bm.action.IRCampaignMgmtAction has an input result:

 <action name="your-action-name" class="com.inrev.bm.action.IRCampaignMgmtAction">
   <result name="input">/WEB-INF/pat/to/input.jsp</result>
   <result name="success">/WEB-INF/pat/to/success.jsp</result>
 </action> 

Update

For your second error, you can see the code that's resulting in the message in the XWorkConverter.getConverter() method (starts at line 366). What Java type is your session property in your com.inrev.bm.action.IRFacebookAction class?

You may have to define a custom type converter to handle this case if it's not something XWork is able to handle by default.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文