Reputation: 251
My Current Working code for resolving html views is like this
<mvc:resources mapping="/static/**" location="/WEB-INF/static/html/" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="" />
<property name="suffix" value=".html" />
</bean>
But i need to return view such as
return "/static/html/index";
How can i make it like this?
return "index";
Upvotes: 1
Views: 1813
Reputation: 2969
if you are using spring Boot, it will automatically add static web resources located within any of the following directories:
/META-INF/resources/
/resources/
/static/
/public/
in case of consuming , restful web service it might be a good approach if you put the resources in to the public folder,and this is how your controller should look like.
@Controller
class Controller{
@RequestMapping("/")
public String index() {
return "index.html";
}
}
Upvotes: 3
Reputation: 3431
Change the prefix to /static/html/
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/static/html/" />
<property name="suffix" value=".html" />
</bean>
So when you will return as "index"
it will change to /static/html/index.html
.
Upvotes: 2