Spring MVC: Contrôleur de RequestMapping de travail, mais de retour donne toujours une erreur 404
J'ai un couple de SYSOUTs dans mon contrôleur de méthodes, et ils apparaissent dans le journal de la console... vérifier pour moi que tous les @RequestMapping se comporte comme prévu. @Permettra à l'autowiring d'un environnement de haricot est aussi de travail (est correctement affiché par un SYSOUT).
Toutefois, les méthodes " de retour (je suis en utilisant des méthodes qui renvoient type de Chaîne) sont seulement résultant en une erreur 404. L' *.les jsp ne sont pas trouvés. Le projet est à l'aide de Maven; l'IDE eclipse kepler, FWIW.
Mon ViewResolver est bog-standard. Ne pouvez pas voir le débrancher.
Mon web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>BluPrint</display-name> <servlet> <servlet-name>mvc-répartiteur</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvc-répartiteur</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <context-param> <param-name>groupId</param-name> <param-value>${projet.groupId}</param-value> </context-param> <context-param> <param-name>artifactId</param-name> <param-value>${projet.artifactId}</param-value> </context-param> </web-app>
Mon servlet.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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:lot="http://www.springframework.org/schema/batch" xmlns:task="http://www.springframework.org/schema/task" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xjp="http://www.corpabc.com/schema/xjp" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd http://www.corpabc.com/schema/xjp http://www.corpabc.com/schema/xjp/beans.xsd"> <context:component-scan de la base-package="com.corpabc.bluprint" /> <mvc:annotation-driven /> <mvc:les ressources de la cartographie="/ressources/**" location="/ressources/" /> <import resource="classpath:corpabc/xjp/configuration/properties.xml" /> <bean id="viewResolver" class="org.springframework.web.servlet.vue.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.vue.JstlView" /> <property name="prefix" valeur="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <bean id="dataSourceDB2" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="jdbc/BluPrint" /> <property name="resourceRef" value="true" /> </bean> <xjp:environnement artifactId="${artifactId}" groupId="${groupId}" /> </haricots>
Mon Controller:
package com.corpabc.bluprint.controllers;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import corpabc.xjp.configuration.env.Environment;
/**
*
* Handles requests for the application.
*/
@Controller
@RequestMapping("/*")
public class BluPrintController {
@Autowired
private Environment xjpEnvironment;
@RequestMapping("/init")
protected String catchInit(Map<String, Object> model) {
System.out.println("Got into init method. XJP Environment: "+xjpEnvironment);
model.put("xjp", this.xjpEnvironment);
return "envtest";
}
@RequestMapping("/*")
protected String catchAllOthers(Map<String, Object> model) {
System.out.println("Got into catch-all method: ");
return "defaultPage";
}
}
Mon envtest.jsp
est sous /WEB-INF/jsp/
... mais en entrant l'URL ~localhost:8080/bluprint/init
... j'obtiens une erreur 404.
Mon defaultPage.jsp
n'existe pas... je m'attends à un pas de condition trouvée ici, et c'est ce que je reçois quand je rentre ~localhost:8080/bluprint/
. Vous ne savez pas si elle doit être une erreur 404, plus précisément, mais c'est ce que je reçois, en tout cas.
OriginalL'auteur David Neuschulz | 2013-10-23
Vous devez vous connecter pour publier un commentaire.
Je pense que votre problème est dans votre servlet de cartographie. /* force tout par le biais de votre répartiteur servlet, y compris les pages jsp. Essayez de perdre l' *. Je vais trouver la partie pertinente dans le servlet de spécification et de mise à jour....
De la servlet spec:
Donc, si vous spécifiez /* remplace le *.jsp de cartographie, de sorte jsp demandes acheminés dans votre répartiteur servlet au lieu de frapper la jsp.
OriginalL'auteur Aaron