简体   繁体   English

Struts2 -ognl异常

[英]Struts2 -ognl Exception

I have a JSP page with an html form . 我有一个带有html表单的JSP页面。 i enter the value of the form fields and hit the submit button the control will go the Action class . 我输入表单字段的值,然后单击“提交”按钮,控件将进入Action类。 My question here is for every field in the JSP page do i need to have a corresponding property in Action class with getters and setters . 我的问题是,对于JSP页面中的每个字段,我都需要在Action类中具有带有getter和setter的相应属性。

I dont have any property defined in my Action class and am trying to fetch value's from the HTML field's . 我在Action类中没有定义任何属性,并且正在尝试从HTML字段的中获取值。 . . i get OGNL Exception 我收到OGNL例外

WARNING: Error setting expression 'Release Version Template' with value '[Ljava.lang.String;@4eb585' ognl.ExpressionSyntaxException: Malformed OGNL expression: Release Version Template [ognl.ParseException: Encountered " "Version "" at line 1, column 9. 警告:设置值为'[Ljava.lang.String; @ 4eb585'的表达式'发行版本模板'时出错ognl.ExpressionSyntaxException:OGNL表达式格式错误:发行版本模板[ognl.ParseException:在第1行的第9。

Is there some workaround for this or should i edit my JSP? 是否有一些解决方法,还是应该编辑我的JSP?

No, you don't have to provide a property for every parameter you're sending with your request. 不,您不必为要随请求发送的每个参数提供属性。 After all it's just a warning that you get and I suspect the reason should be that development mode is enabled in struts.xml. 毕竟这只是一个警告,我怀疑原因应该是在struts.xml中启用了开发模式。

The warning above, on the other hand, seems to indicate that you're passing the value as the parameter name and thus you get the OGNL warning, so please check that (and maybe post the relevant part of your jsp). 另一方面,以上警告似乎表明您正在将值作为参数名称传递,因此您收到了OGNL警告,因此请进行检查(并可能发布jsp的相关部分)。

You can also blacklist or whitelist parameters per application or per action but you'd still get warnings if you send those parameters and have development mode enabled. 您还可以针对每个应用程序或每个操作将参数列入黑名单或白名单,但是如果发送这些参数并启用了开发模式,仍然会收到警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM