私は本の春のレシピから例を作っています.Tomcatに例を展開することはできません. messageList.htm ページを開こうとしていますが、常に HTTP ステータス 404 エラーが発生します。
誰かが私を助けることができますか?
thx事前に
これはコードです:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<:web-app version="2.4" xmlns:="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
<:context-param>
<:param-name>contextConfigLocation</:param-name>
<:param-value>/WEB-INF/board-service.xml</:param-value>
</:context-param>
<:listener>
<:listener-class>org.springframework.web.context.ContextLoaderListener</:listener-class>
</:listener>
<:servlet>
<:servlet-name>Chapter5Security</:servlet-name>
<:servlet-class>org.springframework.web.servlet.DispatcherServlet</:servlet-class>
</:servlet>
<:servlet-mapping>
<:servlet-name>Chapter5Security</:servlet-name>
<:url-pattern>/*</:url-pattern>
</:servlet-mapping>
</:web-app>
board-service.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="messageBoardService" class="service.MessageBoardServiceImpl" />
</beans>
ボードサーブレット.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="web"></context:component-scan>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
MessageListController
@Controller
@RequestMapping("/messageList*")
public class MessageListController {
private MessageBoardService messageBoardService;
@Autowired
public MessageListController(MessageBoardService messageBoardService)
{
this.messageBoardService=messageBoardService;
}
@RequestMapping(method= RequestMethod.GET)
public String generateList(Model model)
{
List<Message>messages=java.util.Collections.emptyList();
messages=messageBoardService.ListMessages();
model.addAttribute("messages",messages);
return "messageList";
}
}
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.glennvdv.BookSpring</groupId>
<artifactId>Chapter5Security</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Chapter5Security Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-acl</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
</dependencies>
<build>
<finalName>Chapter5Security</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<server>myserver</server>
</configuration>
</plugin>
</plugins>
</build>
</project>
messageList.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Message List</title>
</head>
<body>
<c:forEach items="${messages}" var="message">
<table>
<tr>
<td>Author</td>
<td>${message.author}</td>
</tr>
<tr>
<td>Title</td>
<td>${message.title}</td>
</tr>
<tr>
<td>Body</td>
<td>${message.body}</td>
</tr>
<tr>
<td colspan="2">
<a href="messageDelete?messageId=${message.id}">Delete</a>
</td>
</tr>
</table>
<hr />
</c:forEach>
<a href="messagePost">Post</a>
</body>
</html>