问题描述
我有一个类,它看起来是这样的:
I have a class which looks something like this:
public class ScoreDefinition {
protected Boolean primary;
public Boolean isPrimary() {
return primary;
}
public void setPrimary(Boolean value) {
this.primary = value;
}
}
我试图访问它的主
属性EL是这样的:
<c:forEach var="score" items="${scores}">
<input type="checkbox"
value="${score.primary}"
name="someName"
class="textField"/>
</c:forEach>
但我得到异常:
javax.el.PropertyNotFoundException: Property 'primary' not readable on type java.lang.Boolean
at javax.el.BeanELResolver$BeanProperty.read(BeanELResolver.java:280)
at javax.el.BeanELResolver$BeanProperty.access$000(BeanELResolver.java:230)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:81)
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:938)
at org.apache.jsp.WEB_002dINF.views.administer.projectBlocks_jsp._jspx_meth_c_005fforEach_005f2(projectBlocks_jsp.java:806)
at org.apache.jsp.WEB_002dINF.views.administer.projectBlocks_jsp._jspx_meth_c_005fif_005f2(projectBlocks_jsp.java:709)
at org.apache.jsp.WEB_002dINF.views.administer.projectBlocks_jsp._jspx_meth_form_005fform_005f0(projectBlocks_jsp.java:245)
at org.apache.jsp.WEB_002dINF.views.administer.projectBlocks_jsp._jspService(projectBlocks_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:388)
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.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
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 com.groupgti.webclient.filter.SecurityFilter.doFilter(SecurityFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.groupgti.webclient.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:43)
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:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
因为它是从WSDL文件生成的我不能改变这个类。所以,问题是我怎么能解决这个问题,让没有使用任何自定义EL函数转换的布尔
到字符串
或这个对象不是转化为我的吗?是否有可能以某种方式读取EL这个属性没有任何其他修改?
I can not change this class because it is generated from WSDL file. So the question is how can I get around this issue not using any custom EL functions to convert the Boolean
into String
or not converting this object to mine? Is it possible to somehow read this property in the EL without any other modifications?
推荐答案
的是
preFIX是布尔
,不能用于布尔
。
The is
prefix is for boolean
only, not for Boolean
.
您有2个选项:
-
使用
布尔
而不是布尔
。
或者,重命名方法值isPrimary()
到 getPrimary()
。
至于 autogenerating错误的方法,你需要升级到至少JAXB 2.1.13或添加 -B-enableIntrospection
来的电话的wsimport按本的。
As to JAXB blunder of autogenerating the wrong method, you need to upgrade to at least JAXB 2.1.13 or to add -B-enableIntrospection
to the wsimport call as per this JAXB documentation.
- JavaBeans specification - Chapter 8.3.2
- How does Java expression language resolve boolean attributes? (in JSF 1.2)
- JSF 2 checkboxes and boolean getters
这篇关于javax.el.PropertyNotFoundException:房产'富'的java.lang.Boolean类型不可读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!