Erreurs 404 si mon application n'est pas installée à la racine
Bonjour
Je rencontre des problèmes avec une application web Spring que j'ai développé il y a quelques temps. Jusqu'à présent cette app était installée à la racine de mon Tomcat et était donc accessible par www.mondomaine.com:8080 .
Mais je dois intsaller une nouvelle application et cette façon de faire ne sera plus possible. J'ai donc réinstallé mon app et elle est maintenant accessible par www.mondomaine.com:8080/monApp
Mon problème est que quel que soit l'URL une erreur 404 est retournée. Je cherche donc à savoir ce qui manque dans ma configuration :
Mon web.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
<web-app ...>
<display-name>monApp</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/applicationContext.xml
/WEB-INF/spring/spring-security.xml
</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/monApp/*</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/views/errors/404.jsp</location>
</error-page>
</web-app> |
applicationContext
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
<beans ...>
<!-- Activates various annotations to be detected in bean classes -->
<context:annotation-config/>
<context:component-scan base-package="com.mondomaine.monapp"/>
<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/"/>
<import resource="spring-scheduler.xml"/>
<import resource="spring-data.xml"/>
<util:properties id="reportMailProps" location="classpath:/spring/reportMail.properties"/>
<!-- Mail service -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="***"/>
<property name="port" value="***"/>
<property name="username" value="***"/>
<property name="password" value="***"/>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">false</prop>
</props>
</property>
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource" p:basename="messages"/>
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"
p:resourceLoaderPath="classpath:/velocity/">
</bean>
</beans> |
servlet-context.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource" p:basename="messages"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans> |
spring-security.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<sec:http pattern="/resources/**" security="none" />
<sec:http auto-config="true" use-expressions="true" disable-url-rewriting="false">
<sec:headers disabled="true"/>
<sec:csrf disabled="false"/>
<sec:access-denied-handler error-page="/403"/>
<sec:form-login login-page="/login"
default-target-url="/"
login-processing-url="/j_spring_security_check"
username-parameter="username"
password-parameter="password"/>
<sec:logout invalidate-session="true" logout-success-url="/login" logout-url="/logout"/>
<sec:intercept-url pattern="/login/**" access="permitAll" />
<sec:intercept-url pattern="/logout/**" access="permitAll"/>
<sec:intercept-url pattern="/users/add/**" access="hasRole('ROLE_PERM_ADD_USER')"/>
<sec:intercept-url pattern="/users/edit/**" access="hasRole('ROLE_PERM_EDIT_USER')"/>
<sec:intercept-url pattern="/users/delete/**" access="hasRole('ROLE_PERM_DELETE_USER')"/>
<sec:intercept-url pattern="/users/**" access="hasRole('ROLE_PERM_VIEW_USERS_LIST')"/>
<!--[...]-->
<sec:intercept-url pattern="/" access="isAuthenticated()"/>
<sec:intercept-url pattern="/**" access="denyAll"/>-->
</sec:http>
<bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
<constructor-arg name="strength" value="12"/>
</bean>
<bean id="customUserDetailsService" class="ch.pleiades.obs.visites.service.auth.CustomUserDetailsService" />
<sec:authentication-manager>
<sec:authentication-provider user-service-ref="customUserDetailsService">
<sec:password-encoder ref="passwordEncoder" />
</sec:authentication-provider>
</sec:authentication-manager>
</beans> |
et mes contrôleurs ressemblent à ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
@Controller
@RequestMapping("/users")
public class UsersController {
//...
@RequestMapping(value = "", method = RequestMethod.GET)
public String list(Model model) {
return "users/list";
}
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add(Model model) {
//...
return "users/add";
}
//...
} |
Où ai-je commis une erreur ?