我的项目有问题。当我浏览http://localhost:8080/user/form
以显示UserForm,但发生以下错误:
org.apache.jasper.JasperException:javax.servlet.ServletException: javax.servlet .jsp.JspTagException:在代码' Male'下找不到任何消息 对于语言环境' en_US'。 at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspSer vletWrapper.java:585) 在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper) 的.java:455) 在org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:4 05) 在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:349) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 在org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:801 ) 在org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java) :587) 在org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j) AVA:143) 在org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.jav 一:595) 在org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandl er.java:223) 在org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl er.java:1126) 在org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java: 515) 在org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandle r.java:185) 在org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle r.java:1060) 在org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j) AVA:141) 在org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:200) 在org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:75) 在org.springframework.web.servlet.view.InternalResourceView.renderMerge dOutputModel(InternalResourceView.java:209) 在org.springframework.web.servlet.view.AbstractView.render(AbstractView 的.java:267) 在org.springframework.web.servlet.DispatcherServlet.render(DispatcherSe) rvlet.java:1217) 在org.springframework.web.servlet.DispatcherServlet.processDispatchResu LT(DispatcherServlet.java:1005) 在org.springframework.web.servlet.DispatcherServlet.doDispatch(Dispatch erServlet.java:952) 在org.springframework.web.servlet.DispatcherServlet.doService(Dispatche rServlet.java:870) 在org.springframework.web.servlet.FrameworkServlet.processRequest(Frame workServlet.java:961) 在org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServl) et.java:852) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:687) 在org.springframework.web.servlet.FrameworkServlet.service(FrameworkSer vlet.java:837) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 在org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:801 ) 在org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java) :587) 在org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j) AVA:143) 在org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.jav 一:577) 在org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandl er.java:223) 在org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl er.java:1126) 在org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java: 515) 在org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandle r.java:185) 在org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle r.java:1060) 在org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j) AVA:141) 在org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(续 extHandlerCollection.java:215) 在org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerColl ection.java:110) 在org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper 的.java:113) 在org.eclipse.jetty.server.Server.handle(Server.java:509) 在org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:288) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.jav) 一:240) 在org.eclipse.jetty.io.AbstractConnection $ 2.run(AbstractConnection.java :539) 在org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPoo) l.java:620) 在org.eclipse.jetty.util.thread.QueuedThreadPool $ 3.run(QueuedThreadPool) 的.java:540) at java.lang.Thread.run(Thread.java:745)引起:javax.servlet.ServletException:javax.servlet.jsp.JspTagException:否 根据代码'男性'对于语言环境' en_US'。 在org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageC ontextImpl.java:905) at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageCon textImpl.java:834) at org.apache.jsp.WEB_002dINF.pages.UserForm_jsp._jspService(UserForm_js p.java:444) 在org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper) 的.java:432) ... 46更多引起:javax.servlet.jsp.JspTagException:在代码'男性'下找不到任何消息对于语言环境' en_US'。 在org.springframework.web.servlet.tags.MessageTag.doEndTag(MessageTag.j) AVA:202) at org.apache.jsp.WEB_002dINF.pages.UserForm_jsp._jspx_meth_spring_005fm essage_005f0(UserForm_jsp.java:754) at org.apache.jsp.WEB_002dINF.pages.UserForm_jsp._jspService(UserForm_js p.java:318)
此处归档UserForm.jsp
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<html>
<head>
<title>Add New User</title>
</head>
<body>
<h2>Please Input User Information</h2>
<form:form method="POST" modelAttribute="User" action="">
<table>
<tr>
<td><form:label path="userName">UserName</form:label></td>
<td><form:input path="userName"/></td>
<td><form:errors path="userName" /></td>
</tr>
<tr>
<td><form:label path="passWord">Password</form:label></td>
<td><form:input path="passWord"/></td>
<td><form:errors path="passWord" /></td>
</tr>
<tr>
<td><form:label path="birthDay">Birthday</form:label></td>
<td><form:input path="birthDay" type = "date"/> </td>
<td><form:errors path="birthDay"/> </td>
</tr>
<tr>
<td><form:label path="age">Age</form:label>
<td><form:input path="age" type = "number"/> </td>
<td><form:errors path="age"></form:errors> </td>
</tr>
<tr>
<td><form:label path="gender">Gender</form:label></td>
<td><form:select path="gender">
<c:forEach var="temp" items="${allgender}">
<form:option value="${temp}">
<spring:message code="${temp.gender}"/>
</form:option>
</c:forEach>
</form:select></td>
<td><form:errors path="gender"></form:errors></td>
</tr>
<tr><td colspan="3"><input type="submit" value="Submit" /></td></tr>
</table>
</form:form>
</body>
</html>
此处归档Gender.java
package edu.java.spring.service.user.model;
public enum Gender {
MALE("Male"),
FEMALE("Female"),
OTHER("Other");
private String name;
private Gender(String name) {
this.name = name;
}
public String getGender(){
return this.name;
}
}
此处归档pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.java.spring.service</groupId>
<artifactId>springDAT-service</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>springDAT-service Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.12.1.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>springMOTHER-service</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skipTests>true</skipTests>
<argLine>-Xmx2524m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<fork>true</fork>
<compilerArgs>
<arg>-XDignore.symbol.file</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.0.M1</version>
<configuration>
<jvmArgs>-Xmx1048m -Xms536m
-XX:PermSize=128m -XX:MaxPermSize=512m</jvmArgs>
<reload>manual</reload>
<systemProperties>
<systemProperty>
<name>lib</name>
<value>${basedir}/target/spring-mvc/WEB-INF/lib</value>
</systemProperty>
</systemProperties>
<scanIntervalSeconds>3</scanIntervalSeconds>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<contextPath>/</contextPath>
<webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>
<webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
<classesDirectory>${basedir}/target/classes</classesDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:0)
问题是您尝试使用<select>
<option value="1" <c:if test="${user[1] == User}">
</c:if>>User</option>
<option value="2" <c:if test="${user[1] == Player}">
</c:if>> Player </option>
<option value="3" <c:if test="${user[1] == Instructor}">
</c:if>> Instructor</option>
打印<option>
代码的值,但<spring:message>
正在尝试从您不知道的属性文件中加载标签有
尝试替换<spring:message>
的整个<c:foreach />
标记。