My controller name is HelloWorldController and is working fine. I believe the problem is with the mappings but in the book it specifies that the mapping isn't needed because there is one used by default. Can any one help?
I think what the book means is that if you don't return a value for the View String, then it will just go back to the same page it came from. It is the default mechanism.
Originally posted by Mark Spritzler: I think what the book means is that if you don't return a value for the View String, then it will just go back to the same page it came from. It is the default mechanism.
Mark
The view string is a property that goes in the Controller?
No, the return type from a method in a Controller can return a ModelAndView object, or a String (which represents the view to forward to with a ViewResolver), or just a Model object, in which the String for the view is not set. In the case where the View string is not returned, then the default in Spring MVC is to display the same page the request came from. Well, in most cases with the default ViewResolver it will take an incoming request like "http://com.you.site/somepage.htm" then hack off the beginning part and the extension to just get "somepage" use that as the View String, then with the View Resolver prepend and append string to basically send you back to where you were.
Mark
Terril Douglas
Greenhorn
Joined: May 05, 2008
Posts: 11
posted
0
Ok I understand what you are talking about and in my controller I did place the view string in the return. I will just post my Controller:
String aMessage = "Hello World MVC!"; //String lo = null; //ModelAndView modelAndView = new ModelAndView();
return new ModelAndView("hello_world","message",aMessage); } }
Terril Douglas
Greenhorn
Joined: May 05, 2008
Posts: 11
posted
0
Hey Mark I think the problem was that my app was going in a loop because the view was the same component that was used to refer to my bean name in the springmvc-server.xml file. So essentially when it returned from the controller the request then looked to use the view which was referring right back to the bean. Sorry for any inconvenience.
Originally posted by Terril Douglas: Hey Mark I think the problem was that my app was going in a loop because the view was the same component that was used to refer to my bean name in the springmvc-server.xml file. So essentially when it returned from the controller the request then looked to use the view which was referring right back to the bean. Sorry for any inconvenience.
No inconvenience. That is why we are here, maybe to help, or maybe to help you find it yourself despite me.
Mark
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.