Struts 2 setter 未知字段参数

发布于 2024-12-21 14:57:14 字数 887 浏览 1 评论 0原文

我的 struts 2 (2.3.1) 应用程序在调试模式下的 url http://localhost/app/check.action?13239 引发了此类异常

2011-12-15 14:45:06,455 DEBUG [CommonsLogger.java:68] : Setting static parameters {}
2011-12-15 14:45:06,456 DEBUG [CommonsLogger.java:68] : Setting params NONE
2011-12-15 14:45:06,456 DEBUG [CommonsLogger.java:68] : Setting params 13239 => [  ]
2011-12-15 14:45:06,461 WARN  [CommonsLogger.java:60] : Error setting expression '13239' with value '[Ljava.lang.String;@33b4450e'
ognl.InappropriateExpressionException: Inappropriate OGNL expression: 13239
        at ognl.SimpleNode.setValueBody(SimpleNode.java:312)
        at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
        at ognl.SimpleNode.setValue(SimpleNode.java:301)

我希望根据文档默默地忽略它们。解决这个问题的正确方法是什么?

顺便说一句,struts 似乎在寻找值 13239 的 setter 字段,但我猜它不适合以数字开头的属性。

My struts 2 (2.3.1) application at debug mode for url http://localhost/app/check.action?13239 raises such kind of exceptions

2011-12-15 14:45:06,455 DEBUG [CommonsLogger.java:68] : Setting static parameters {}
2011-12-15 14:45:06,456 DEBUG [CommonsLogger.java:68] : Setting params NONE
2011-12-15 14:45:06,456 DEBUG [CommonsLogger.java:68] : Setting params 13239 => [  ]
2011-12-15 14:45:06,461 WARN  [CommonsLogger.java:60] : Error setting expression '13239' with value '[Ljava.lang.String;@33b4450e'
ognl.InappropriateExpressionException: Inappropriate OGNL expression: 13239
        at ognl.SimpleNode.setValueBody(SimpleNode.java:312)
        at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
        at ognl.SimpleNode.setValue(SimpleNode.java:301)

I was expecting silently ignoring them according to documentation. What is the correct way to fix this problem?

By the way it seems that struts looking for a setter field for the value 13239 however I guess that it is not suitable for a property which is started by a number.

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

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

发布评论

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

评论(1

孤星 2024-12-28 14:57:14

这或多或少是您个人品味的问题。有时,我们想知道任何时候提交的参数在操作上没有匹配的 getter/setter,并且它是开发我们的应用程序的常见用例,但我们忘记了对于某个操作的 getter/setter,我们想了解任何可能的错误情况。

一种可能的方法是将开发和生产的日志记录级别设置为不同的。在 Struts2 邮件列表上对此进行了很长的讨论,这里是相同

OgnlValueStack 从 struts 2 升级到 struts 后设置表达式警告时出错2.1.7

That is more or less a issue of your personal taste.Sometime we wants to know any time a parameter is submitted that doesn't have a matching getter/setter on the action and its a common use case in development our application and we forget a getter/setter on an action, we want to know about any possible error case.

One possible way to is setting the logging level differently from dev to production.There was a long discussion about this on Struts2 mailing list here is the link for same

OgnlValueStack Error setting expression warnings after upgrade from struts 2 to struts 2.1.7

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