By default, where does Spring Boot expect views to be stored?

The Solution I found the answer via trial-and-error, which turned out rather annoying. I hope someone can correct me if this conclusion is wrong, but it appears that Spring Boot does not like the string WEB-INF. I renamed the WEB-INF directory to view and changed the application.properties to the following and the view loaded successfully. … Read more

How to use with an tag?

<spring:url value=”/something” var=”url” htmlEscape=”true”/> <a href=”https://stackoverflow.com/questions/5007210/${url}”>…</a> But you an also use c:url <c:url value=”/something” var=”url”/> <a href=”https://stackoverflow.com/questions/5007210/<c:out value=”https://stackoverflow.com/questions/5007210/${url}”/>”>…</a> The one important difference between c:url and spring:url is, that c:url does not html encode the created url. But for a valid url the & between the url parameters must be a &amp;. So you need the … Read more

Thymeleaf multiple submit button in one form

You can create separate methods with different @RequestMappings using the params variable. @RequestMapping(value=”/edit”, method=RequestMethod.POST, params=”action=save”) public ModelAndView save() {} @RequestMapping(value=”/edit”, method=RequestMethod.POST, params=”action=cancel”) public ModelAndView cancel() {}

My Application Could not open ServletContext resource

Quote from the Spring reference doc: Upon initialization of a DispatcherServlet, Spring MVC looks for a file named [servlet-name]-servlet.xml in the WEB-INF directory of your web application and creates the beans defined there… Your servlet is called spring-dispatcher, so it looks for /WEB-INF/spring-dispatcher-servlet.xml. You need to have this servlet configuration, and define web related beans … Read more

how to set header no cache in spring mvc 3 by annotation

There is no such option. You can use an interceptor: <mvc:annotation-driven/> <mvc:interceptors> <bean id=”webContentInterceptor” class=”org.springframework.web.servlet.mvc.WebContentInterceptor”> <property name=”cacheSeconds” value=”0″/> <property name=”useExpiresHeader” value=”true”/> <property name=”useCacheControlHeader” value=”true”/> <property name=”useCacheControlNoStore” value=”true”/> </bean> </mvc:interceptors> (taken from here) On one hand it is logical not to have such annotation. Annotations on spring-mvc methods are primarily to let the container decide which … Read more

spring mvc get all request mappings

I am replicating one of my previous answers here: If you are using Spring 3.1 this handlerMapping component is an instance of RequestMappingHandlerMapping, which you can query to find the handlerMappedMethods and the associated controllers, along these lines(if you are on an older version of Spring, you should be able to use a similar approach): … Read more

Spring MVC – Binding a Date Field

How does the Spring MVC determine the type of a given request parameter ? Spring makes use of ServletRequestDataBinder to bind its values. The process can be described as follows /** * Bundled Mock request */ MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter(“name”, “Tom”); request.addParameter(“age”, “25”); /** * Spring create a new command object before processing … Read more