PDA

View Full Version : ${message} not displayed!


sim085
Apr 26th, 2006, 09:02 AM
Hello,

I managed to get my first page loading with Spring, however I am finding a difficulty regarding the displaying messages set from the controller on the jsp page.

Now, I am a little new to Spring, however in the book I am reading I have the example as follows:


<html>
<head>. . .</head>
<body>
<h2>${message}</h2>

</body>
</html>


Now my problem is that my page is loading successfully, I also placed a System.out.println in my controller to see if it is passing from it and yes it is :) (Was so happy to see that :).

However in the page I get printed ${message} and not the message I am setting in the ModelAndView.


return new ModelAndView("home", "message", "vavavoom");


Now, I did not give up on seeing that :) I found a tutorial (as I think I said in another post) called Spring MVC Step by Step. In this one it prints the message doing as follows:


<c:out value="${prod.description}"/>


Now my question is, do I need that c:out thing? Or I should have my message rapped all the same. In my app-servlet.xml I also have the view resolve set as follows:


<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>

This seems to be working fine since my page is being find and displayed successfully (this means in the URL I insert home.htm, and it returns the data from home.jsp).

I am planning to start using FreeMarker after this, however would really like to know whether I should have any message displayed to me before passing to the next step.

Thanks and Regards,
Sim085

EndlessWinter
Apr 26th, 2006, 10:24 AM
You need c:out if your container doesn't support JSP 2, or if you webapp deployed with web.xml referenced servlet version below 2.4

betabagel
Apr 26th, 2006, 11:08 AM
Your problem seems a tad like my dilemma yesterday.
You can read the thread here (http://forum.springframework.org/showthread.php?p=59209#post59209)

In shorttext you have to alter your web.xml to get all going. Maybe also make sure you are using jstl.jar v1.1. Well. It's all there...

sim085
Apr 27th, 2006, 03:58 AM
Hi,

Thanks for your all your posts :) I tought of trying that out, but then I decided to go strait to FreeMarker and it worked fine :) thanks a lot for all the help :)

regards,
sim085

sim085
May 2nd, 2006, 07:04 AM
Your problem seems a tad like my dilemma yesterday.
You can read the thread here (http://forum.springframework.org/showthread.php?p=59209#post59209)

In shorttext you have to alter your web.xml to get all going. Maybe also make sure you are using jstl.jar v1.1. Well. It's all there...

I checked your post :) and did what you said :) and it worked :) thanks one more time.

regards,
sim085