无法理解错误

时间:2016-12-30 17:18:32

标签: java jsf tomcat xhtml

标识符[#]不是EL规范1.19节(标识符:: = Java语言标识符)所要求的有效Java标识符。可以通过设置系统属性

来禁用此检查
org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true.

-im使用tomcat 8服务器。

表单页面:

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h = "http://xmlns.jcp.org/jsf/html"
    xmlns:f = "http://xmlns.jcp.org/jsf/core" >
    <h:head>
    <title>Health Plan</title>
    </h:head>
    <h:body>
    <h:form>
    <h1>Health Care Sign up</h1>

    <!-- 
    Employee Name: <h:inputText value = "#{employee.name}" id="name" /> <br/>

    Empolyee ID: <h:inputText value = "#{employee.id}" /> <br/>
    Health Plan Name:
    <h:selectOneMenu value="#{employee.healthPlanS}" >
    <f:selectItems value="#{healthPlanOptions.heathPlanArrayList}"   var="healthPlan" itemLabel="#{healthPlan.planName}" itemValue="#  {healthPlan.planName}" />
    </h:selectOneMenu>
    -->

    <br/>

    <h:commandButton value= "submit" action="ConfirmRegistration" />
    </h:form>
    </h:body>
    </html>

confirmregistration

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h ="http://xmlns.jcp.org/jsf/html"
>
<h:head>
<title>Confirmation</title>
</h:head>
<h:body>
<ul>
<!-- <li>Employee Name: #{ employee.name } </li>
<li>Employee ID: #{ employee.id } </li>
<li>Health Plan Selected: #{employee.healthPlanS} </li>
<li>Monthly premium: #{healthPlanOption.price(#{healthPlanS})}</li>
<li>contact number :4697654</li> -->
</ul>
</h:body>
</html>

这两个文件都保存了.xhtml

使用的bean:

import javax.faces.bean.ManagedBean;

@ManagedBean
public class Employee {
    private String name, id, healthPlanS;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getHealthPlanS() {
        return healthPlanS;
    }

    public void setHealthPlanS(String healthPlanS) {
        this.healthPlanS = healthPlanS;
    }

}

HealthPlan:

import javax.faces.bean.ManagedBean;

@ManagedBean
public class HealthPlan {

    private String planName, planPrice;

    public HealthPlan() {
    }

    public HealthPlan(String name, String price) {
        this.planName = name;
        this.planPrice = price;

    }

    public String getPlanName() {
        return planName;
    }

    public void setPlanName(String planName) {
        this.planName = planName;
    }

    public String getPlanPrice() {
        return planPrice;
    }

    public void setPlanPrice(String planPrice) {
        this.planPrice = planPrice;
    }

}

HealthPlanOption:

import java.util.ArrayList;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class HealthPlanOptions {

    private ArrayList<HealthPlan> heathPlanArrayList;

    public HealthPlanOptions() {
        heathPlanArrayList = new ArrayList<HealthPlan>();

        heathPlanArrayList.add(new HealthPlan("Heath Care", "1555.5$"));
        heathPlanArrayList.add(new HealthPlan("Heath Care 2", "1959.10$"));

    }

    public ArrayList<HealthPlan> getHeathPlanArrayList() {
        return heathPlanArrayList;
    }

    public void setHeathPlanArrayList(ArrayList<HealthPlan> heathPlanArrayList) {
        this.heathPlanArrayList = heathPlanArrayList;
    }


}

请注意:

代码原样(带注释)会出现以下错误:

SEVERE:Servlet [Faces Servlet]的Servlet.service()在路径[/ jsf_2]的上下文中引发异常[标识符[#]不是EL规范第1.19节所要求的有效Java标识符(标识符: := Java语言标识符)。可以通过将系统属性org.apache.el.parser.SKIP_IDENTIFIER_CHECK设置为true来禁用此检查。 javax.el.E​​LException:标识符[#]不是EL规范1.19节(标识符:: = Java语言标识符)所要求的有效Java标识符。可以通过将系统属性org.apache.el.parser.SKIP_IDENTIFIER_CHECK设置为true来禁用此检查。     在org.apache.el.parser.AstIdentifier.setImage(AstIdentifier.java:177)     在org.apache.el.parser.ELParser.Identifier(ELParser.java:1816)     在org.apache.el.parser.ELParser.NonLiteral(ELParser.java:1548)     在org.apache.el.parser.ELParser.ValuePrefix(ELParser.java:1369)     在org.apache.el.parser.ELParser.Value(ELParser.java:1316)     在org.apache.el.parser.ELParser.Unary(ELParser.java:1298)     在org.apache.el.parser.ELParser.Multiplication(ELParser.java:1060)     在org.apache.el.parser.ELParser.Math(ELParser.java:980)     在org.apache.el.parser.ELParser.Concatenation(ELParser.java:936)     在org.apache.el.parser.ELParser.Compare(ELParser.java:747)     在org.apache.el.parser.ELParser.Equality(ELParser.java:641)     在org.apache.el.parser.ELParser.And(ELParser.java:585)     在org.apache.el.parser.ELParser.Or(ELParser.java:529)     在org.apache.el.parser.ELParser.Choice(ELParser.java:486)     在org.apache.el.parser.ELParser.Assignment(ELParser.java:243)     在org.apache.el.parser.ELParser.Semicolon(ELParser.java:182)     在org.apache.el.parser.ELParser.Expression(ELParser.java:175)     在org.apache.el.parser.ELParser.MethodParameters(ELParser.java:1486)     在org.apache.el.parser.ELParser.ValueSuffix(ELParser.java:1397)     在org.apache.el.parser.ELParser.Value(ELParser.java:1328)     在org.apache.el.parser.ELParser.Unary(ELParser.java:1298)     在org.apache.el.parser.ELParser.Multiplication(ELParser.java:1060)     在org.apache.el.parser.ELParser.Math(ELParser.java:980)     在org.apache.el.parser.ELParser.Concatenation(ELParser.java:936)     在org.apache.el.parser.ELParser.Compare(ELParser.java:747)     在org.apache.el.parser.ELParser.Equality(ELParser.java:641)     在org.apache.el.parser.ELParser.And(ELParser.java:585)     在org.apache.el.parser.ELParser.Or(ELParser.java:529)     在org.apache.el.parser.ELParser.Choice(ELParser.java:486)     在org.apache.el.parser.ELParser.Assignment(ELParser.java:243)     在org.apache.el.parser.ELParser.Semicolon(ELParser.java:182)     在org.apache.el.parser.ELParser.Expression(ELParser.java:175)     在org.apache.el.parser.ELParser.DeferredExpression(ELParser.java:113)     在org.apache.el.parser.ELParser.CompositeExpression(ELParser.java:41)     在org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:111)     在org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:168)     在org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:232)     在org.apache.el.E​​xpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:67)     at com.sun.faces.facelets.el.E​​LText $ ELTextVariable.apply(ELText.java:203)     at com.sun.faces.facelets.el.E​​LText $ ELTextComposite.apply(ELText.java:184)     在com.sun.faces.facelets.compiler.CommentInstruction.apply(CommentInstruction.java:81)     在com.sun.faces.facelets.compiler.UIInstructionHandler.apply(UIInstructionHandler.java:141)     在javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)     at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:190)     在javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)     在javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)     at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)     at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)     在com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:161)     在com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:972)     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)     在com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)     在com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)     在javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)     在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)     在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)     在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)     在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)     在org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)     在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)     在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)     在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1100)     at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:687)     在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1520)     在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.run(NioEndpoint.java:1476)     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source)     at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     在java.lang.Thread.run(未知来源)

1 个答案:

答案 0 :(得分:0)

哦,它现在有效。 首先我有

<li>Monthly premium: #{healthPlanOption.price(#{healthPlanS})}</li>

导致同样的错误。 第二个评论块。 谢谢@balbus 你的野兽:)