gpt4 book ai didi

java - 处理 JSP page/WEB-INF/views/ViewPage.jsp 第 130 行时发生异常

转载 作者:行者123 更新时间:2023-11-30 07:40:31 24 4
gpt4 key购买 nike

在 Servlet.xml 中

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="messages"/>
<property name="defaultEncoding" value="UTF-8" />
</bean>

在 src/resources/messages.properties 文件中的 messages.properties 文件中

label.employeeId=Emp.ID
label.employeeName=Employee Name
label.dateOfBirth=DOB
label.annualIncome=Annual Income
label.bloodGroup=Blood group
label.qualification=Qualification
label.sex=Sex
label.phoneNumber=Phone No.
label.email=Email
label.edit=Edit
label.delete=Delete

jsp 文件代码片段和标签。

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ page session="false" %>

<table border="0" cellpadding="0" cellspacing="0">

<tr>
<td width="5%"><label for="Emp.ID"><spring:message code="label.employeeId"/></label></td>
<td width="22%"><label for="Employee Name"><spring:message code="label.employeeName"/></label></td>
<td width="6%"><label for="DOB"><spring:message code="label.dateOfBirth"/></label></td>
<td width="7%"><label for="Annual Income"> <spring:message code="label.annualIncome"/></label> </td>
<td width="9%"><label for="Blood group"> <spring:message code="label.bloodGroup"/></label> </td>
<td width="11%"><label for="Qualification"> <spring:message code="label.qualification"/></label></td>
<td width="7%"><label for="Sex"> <spring:message code="label.sex"/></label></td>
<td width="10%"><label for="Phone No."> <spring:message code="label.phoneNumber"/></label></td>
<td width="9%"><label for="Email"> <spring:message code="label.email"/></label></td>
<td width="7%"><label for="Edit"> <spring:message code="label.edit"/></label></td>
<td width="7%"><label for="Delete"> <spring:message code="label.delete"/></label></td>

</tr>

当我运行这个程序时,我收到如下错误

     Exception report
message An exception occurred processing JSP page /WEB-INF/views/ViewPage.jsp at line 130
description The server encountered an internal error that prevented it from fulfilling this request.
Exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/ViewPage.jsp at line 130
127: <table border="0" cellpadding="0" cellspacing="0">
128:
129: <tr>
130: <td width="5%"><label for="Emp.ID"><spring:message code="label.employeeId"/></label></td>
131: <td width="22%"><label for="Employee Name"><spring:message code="label.employeeName"/></label></td>
132: <td width="6%"><label for="DOB"><spring:message code="label.dateOfBirth"/></label></td>
133: <td width="7%"><label for="Annual Income"> <spring:message code="label.annualIncome"/></label> </td>

堆栈跟踪:

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'label.employeeId' for locale 'en_US'.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845)
org.apache.jsp.WEB_002dINF.views.ViewPage_jsp._jspService(ViewPage_jsp.java:264)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

javax.servlet.jsp.JspTagException: No message found under code 'label.employeeId' for locale 'en_US'.
org.springframework.web.servlet.tags.MessageTag.doStartTagInternal(MessageTag.java:184)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
org.apache.jsp.WEB_002dINF.views.ViewPage_jsp._jspx_meth_spring_005fmessage_005f0(ViewPage_jsp.java:420)
org.apache.jsp.WEB_002dINF.views.ViewPage_jsp._jspService(ViewPage_jsp.java:195)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

当运行我的程序时,我遇到了上述错误,我已经发布了我的属性文件、jsp 文件和 servlet.xml 文件,请帮助我修复此错误。我已将 messages.properties 文件放置在 src/resource 文件夹/messages.properties 文件

最佳答案

异常的根本原因很明确:

javax.servlet.jsp.JspTagException: No message found under code 'label.employeeId' for locale 'en_US'.

在您的属性文件中,您缺少属性label.employeeId。请将其添加到您的 messages.properties 属性文件中。

更正:由于您的属性文件中已有 label.employeeId,因此您的文件位置可能位于错误的位置。也许它应该位于 src/main/resources/目录中(如果您的项目是 Maven 化的)。

关于java - 处理 JSP page/WEB-INF/views/ViewPage.jsp 第 130 行时发生异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34759863/

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