我看起来像一个菜鸟错误,但似乎我无法通过它。我正在学习JSP和Spring,并且在我的项目中遇到了404错误。 我正在使用一个tomcat 8.0本地服务器。我的目标是从“http://localhost:8080/TestSpring/vues/bonjour.jsp”去“http://localhost:8080/TestSpring/bonjour”有教程的帮助,但是这会导致一个404简单的JSP页面404错误
“调度员servlet.xml中”
<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"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:component-scan base-package="be.knoware" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/vues/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="ISO-8859-1" />
</bean>
网络。 XML
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Declaration de la servlet de Spring et de son mapping -->
<servlet>
<servlet-name>servlet-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>servlet-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
bonjour.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" isELIgnored="false"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><spring:message code="titre.bonjour"/> ${personne}</title>
</head>
<body>
<spring:message code="libelle.bonjour.lemonde" arguments="${personne}"/>
</body>
</html>
BonjourController.java
package controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/bonjour")
public class BonjourController {
@RequestMapping(method = RequestMethod.GET)
public String afficherBonjour(final ModelMap pModel){
pModel.addAttribute("personne","Jim");
return "bonjour";
}
}
如果它可能会帮助,该项目。
感谢提前:)
是您的应用程序成功地部署在服务器? –
@Subodh是的,我想是的(如果这是你的意思,部署[链接](http://imgur.com/AOrBi8l)),并有我的服务器启动时的控制台文本,我尝试连接到URL 。 [链接](http://pastebin.com/zvXLQfn7) – Erunayc
在日志中会清楚地显示项目是否已部署 –