在第130行处理JSP页面/WEB-INF/views/ViewPage.jsp时发生异常

时间:2016-01-13 06:32:16

标签: java spring jsp

在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 s文件夹/ messages.properties文件

1 个答案:

答案 0 :(得分:1)

异常的根本原因是明确的:

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

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

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