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
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