Obter objeto da request usando WebWork

2 respostas
X

Pessoal,

abram aki:
http://wiki.opensymphony.com/display/WW/TutorialLesson06

<html>
<head>
<title>WebWork Tutorial - Lesson 5 - Example 1</title>
</head>
<body>

#set ($ses = $req.getSession())
<p><b>${ses.getAttribute('greeting')}!</b></p>

</body>
</html>

Como fazer em jsp e não em velocity?Fiz com:

<ww:property value="#session.greeting"/> e de não deu!

Desde já obrigado pela resposta.

2 Respostas

marciobarroso

Uma dica para vc obter sua resposta mais rápido :

Use o campo assunto do novo post para descrever seu problema:
Ex.: Obter objeto da request usando WebWork e Velocity

[]'s

X
De outra forma:
public class GreetingInterceptor implements Interceptor {
	public void init() { }
	public void destroy() { }
	public String intercept(ActionInvocation invocation) throws Exception {
		Calendar calendar = Calendar.getInstance();
		int hour = calendar.get(Calendar.HOUR_OF_DAY);
		String [b]greeting[/b] = (hour < 6) ? "Good evening" : 
			((hour < 12) ? "Good morning": 
			((hour < 18) ? "Good afternoon": "Good evening"));

		invocation.getInvocationContext().getSession().put("greeting", greeting);

		String result = invocation.invoke();

		return result;
	}

Como pegar o greeting e mostrar no jsp? Já pesquisei e nada! Sei como fazer para os form´s mas quando o valor vem do interceptor ... nao sei! Alguem sabe... ou é mesmo muito dificil? :shock: uuuu

Criado 12 de novembro de 2006
Ultima resposta 13 de nov. de 2006
Respostas 2
Participantes 2