salut,

j'ai un problème avec le ${message} dans ma page jsp. Lors de l'affichage il m'affiche "${message}" et non pas le message que j'ai injecté.

HomeController.java

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
package com.ncs.spring.controllers;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
 
 
public class HomeController implements Controller {
 
	private String greeting;
 
	public void setGreeting(String greeting) {
		this.greeting = greeting;
	}
 
	public ModelAndView handleRequest(HttpServletRequest request,
							HttpServletResponse response) throws Exception {
 
		return new ModelAndView("home", "message", greeting);
	}
}
home.jsp

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<h1>The message is </h1>
	<h2>${message}</h2>
</body>
</html>
WEB-INF/applicationContext.xml

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
49
50
51
52
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
 
<beans>
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="configLocation">
			<value>classpath:hibernate.cfg.xml</value>
		</property>
	</bean>
	<bean id="EtudiantDAO" class="com.ncs.hibernate.EtudiantDAO">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean name="/home.form"
		class="com.ncs.spring.controllers.HomeController">
		<property name="greeting">
			<value>
				Bienvenu
			</value>
		</property>
	</bean>
	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix">
			<value>/</value>
		</property>
		<property name="suffix">
			<value>.jsp</value>
		</property>
	</bean>
	<bean name="/etudiant.form"
		class="com.ncs.spring.controllers.EtudiantController">
		<property name="etudiantDAO">
			<ref bean="EtudiantDAO" />
		</property>
		<property name="formView">
			<value>simpleform</value>
		</property>
		<property name="successView">
			<value>etudiantRegistred</value>
		</property>
		<property name="validator">
			<ref bean="Etudiant.Validator" />
		</property>
	</bean>
	<bean id="Etudiant.Validator"
		class="com.ncs.spring.validators.EtudiantValidator">
	</bean>
	</beans>