简单的 JSF 应用程序给出 Jasper 异常,引用属性名称是唯一的
这是我得到的错误日志
org.apache.jasper.JasperException: /pages/inputname.jsp (line: 3, column: 50) Attribute qualified names must be unique within an element
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:171)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:153)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1236)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1450)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:239)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:197)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:469)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
org.apache.jsp.index_jsp._jspService(index_jsp.java:60)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
JSP 页面的代码是
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<f:loadBundle var="test.bundle.messages" var="msg"/>
<html>
<head>
<title>enter your name page</title>
</head>
<body>
<f:view>
<h1>
<h:outputText value="#{msg.inputname_header}"/>
</h1>
<h:form id="helloForm">
<h:outputText value="#{msg.prompt}"/>
<h:inputText value="#{personBean.personName}" />
<h:commandButton action="greeting" value="#{msg.button_text}" />
</h:form>
</f:view>
</body>
</html>
对于 messages.properties 文件,它是
inputname_header=JSF KickStart
prompt=Tell us your name:
greeting_text=Welcome to JSF
button_text=Say Hello
sign=!
这里出了什么问题?
This is the Error log i got
org.apache.jasper.JasperException: /pages/inputname.jsp (line: 3, column: 50) Attribute qualified names must be unique within an element
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:171)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:153)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1236)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1450)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:239)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:197)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:469)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
org.apache.jsp.index_jsp._jspService(index_jsp.java:60)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
The code for the JSP page is
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<f:loadBundle var="test.bundle.messages" var="msg"/>
<html>
<head>
<title>enter your name page</title>
</head>
<body>
<f:view>
<h1>
<h:outputText value="#{msg.inputname_header}"/>
</h1>
<h:form id="helloForm">
<h:outputText value="#{msg.prompt}"/>
<h:inputText value="#{personBean.personName}" />
<h:commandButton action="greeting" value="#{msg.button_text}" />
</h:form>
</f:view>
</body>
</html>
And for the messages.properties file it is
inputname_header=JSF KickStart
prompt=Tell us your name:
greeting_text=Welcome to JSF
button_text=Say Hello
sign=!
Whats going wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误包含行号和字符位置:
因此,
错误消息显示:
再看一次,您已声明
var
属性两次。第一个应该是basename
。相应地修复它:与具体问题无关,因为 2.5 年前 JSF 已经升级到 JSF 2.0,并且 JSP 已被 Facelets 取代。我强烈建议您更新您的课程/学习材料/书籍/教程。它们已经过时了。
The error contains the line number and the character position:
That's thus
The error message says:
Look once again, you've declared
var
attribute twice. The first one should have beenbasename
. Fix it accordingly:Unrelated to the concrete problem, since over 2.5 years ago JSF has been upgraded to JSF 2.0 and JSP has been succeeded by Facelets. I'd strongly recommend to refresh your course/learning materials/books/tutorials. They are out of date.