這個問題是我碰到的一個比較糾結的問題,如果第一次碰到肯定能讓你也很糾結,哈哈
[c-sharp] view plaincopyprint?01.2010-10-19 18:27:22 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn 02.警告: Error setting expression 'nnew.nTitle' with value '[Ljava.lang.String;@df804e' 03.ognl.NoSuchPropertyException: com.center.vo.News_Table.nTitle [java.lang.IllegalAccessException: Class ognl.OgnlRuntime can not access a member of class com.center.vo.News_Table with modifiers "private"] 04. at ognl.OgnlRuntime.setFieldValue(OgnlRuntime.java:1663) 05. at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:87) 06. at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162) 07. at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27) 08. at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2245) 09. at ognl.ASTProperty.setValueBody(ASTProperty.java:127) 10. at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) 11. at ognl.SimpleNode.setValue(SimpleNode.java:301) 12. at ognl.ASTChain.setValueBody(ASTChain.java:227) 13. at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) 14. at ognl.SimpleNode.setValue(SimpleNode.java:301) 15. at ognl.Ognl.setValue(Ognl.java:737) 16. at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:209) 17. at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:173) 18. at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:160) 19. at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:151) 20. at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:288) 21. at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:199) 22. at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 23. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 24. at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) 25. at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 26. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 27. at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190) 28. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 29. at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) 30. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 31. at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) 32. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 33. at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243) 34. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 35. at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) 36. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 37. at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) 38. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 39. at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) 40. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 41. at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142) 42. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 43. at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166) 44. at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 45. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 46. at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176) 47. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 48. at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) 49. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 50. at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190) 51. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 52. at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187) 53. at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 54. at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) 55. at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485) 56. at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) 57. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 58. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 59. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 60. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 61. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 62. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 63. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 64. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 65. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) 66. at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 67. at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) 68. at java.lang.Thread.run(Unknown Source) 69.Caused by: java.lang.IllegalAccessException: Class ognl.OgnlRuntime can not access a member of class com.center.vo.News_Table with modifiers "private" 70. at sun.reflect.Reflection.ensureMemberAccess(Unknown Source) 71. at java.lang.reflect.Field.doSecurityCheck(Unknown Source) 72. at java.lang.reflect.Field.getFieldAccessor(Unknown Source) 73. at java.lang.reflect.Field.set(Unknown Source) 74. at ognl.OgnlRuntime.setFieldValue(OgnlRuntime.java:1655)
引起這種原因就是屬性名稱的不規範!!就像上面的錯誤資訊中寫出的,"nTitle"這樣的屬性名稱產生set和get方法是不規範的!所以struts2用DomainModel傳遞參數,會引起struts2的"誤會"!!是不是很糾結啊