问题描述
第一次用的ibatis结合struts2,不明白为什么jsp页面一用EL表达式就报错,这个UserID属性都设置getset 方法了jsp页面出错的地方<input type="hidden" name="userId" value="${userInfo.UserID}">异常:javax.el.PropertyNotFoundException: Property 'UserID' not found on type com.shop.entity.UserInfoat javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193)at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:170)at javax.el.BeanELResolver.property(BeanELResolver.java:279)at javax.el.BeanELResolver.getValue(BeanELResolver.java:60)at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) at org.apache.el.parser.AstValue.getValue(AstValue.java:123)at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:935)at org.apache.jsp.advice.users.updateUserInfo_jsp._jspService(updateUserInfo_jsp.java:150)at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:154)at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)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)at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)at java.lang.Thread.run(Thread.java:619) 问题补充:dunedain 写道
解决方案
和那个没有关系,el表达式取值时是根据getXXX来的,如果bean有一个getXXX()方法(对于布尔值则是isXXX()方法)则认为有一个xXX属性(去掉get或is并将首字母小写)
解决方案二:
${userInfo.UserID}U小写