gpt4 book ai didi

java - 无法理解什么是错误

转载 作者:行者123 更新时间:2023-11-29 00:01:42 25 4
gpt4 key购买 nike

标识符[#]不是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>




确认注册

<?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

使用的豆:

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;
}

}


健康计划:

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;
}


}


注意:

代码本身(带有注释)给出以下错误:

严重:路径为[/ jsf_2]的上下文中的Servlet [Faces Servlet]的Servlet.service()抛出异常[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)
    在com.sun.faces.facelets.el.E​​LText $ ELTextVariable.apply(ELText.java:203)
    在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)
    在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)
    在com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
    在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)
    在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)
    在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    在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)
    在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)
    在java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)
    在java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源)
    在org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)
    在java.lang.Thread.run(未知来源)

最佳答案

哦,它现在可以工作了。
首先我有

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


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

关于java - 无法理解什么是错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41400066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com