How does spring resolves the view when we return as String? -
While the model resolves the view in Dispatcher servlet returning as spring, but < Strong> string How to fix the Spring view
@RequestMapping (value = "/", method = RequestMethod.GET) Public string home (locale locale, model model) { Date Date = New Date (); Date format date format = date format.get date timestine (date format.long, date format.html, locale); String formatteddate = dateformat. Format (date); Model.addAttribute ("servertime", formatted date); Println ("serverTime" + formattedDate); Return "resource / home.html"; }
Here I return a string in the code above which dispatcherslate resolves its view.
This is a visual resolver, which mappers between logical names and actual resources, not dispatcher serials.
I think that you will have a declaration ( some different resolutions may be Resolver ), in your configuration file.
& lt; Bean square = "org.springframework.web.servlet.view.InternalResourceViewResolver" & gt; & Lt; Property Name = "Prefix" & gt; & Lt; Price & gt; / Web-INF /
So when you type "home.jsp" inside your controller, then mapping this resource to /WEB-INF/home.jsp
Resolver to see the work and Resolver. See resolvers simply prefix and suffix on your logical name and mapping the actual resource.
Comments
Post a Comment