Problème avec une variable dans une page .jsp
Bonjour,
Mon problème c'est que je souhaite accéder à ma variablle ${msg} dans ma page jsp avec la méthode addObject("msg","test") de mon contrôleur mais cette dernière ne se modifie pas.
Je poste directement le problème que j'ai rencontré
C'est ma page HelloPage
Code:
1 2 3 4 5 6 7
|
<html>
<body>
<h2>${msg}</h2>
</body>
</html> |
C'est mon contrôleur HelloController:
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
|
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
//@RequestMapping("/greet")
public class HelloController{
@RequestMapping("/welcome/{countryName}/{userName}")
public ModelAndView helloWord(@PathVariable Map<String, String> urlList){
String name=urlList.get("userName");
String country=urlList.get("countryName");
ModelAndView modelAndView=new ModelAndView("HelloPage");
System.out.println("Vous êtes à "+country+" M "+name+" :)");
modelAndView.addObject("msg", "hello "+name);
return modelAndView;
}
} |
et voici ma servlet dispatcher:
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
|
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.gontuseries.hellocontroller" />
<mvc:annotation-driven/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans> |