I'm trying to use spring with angularjs, so i need default page to be a html file. Here i saw that can map an url to a directory location using mvc:resources
but can't made it works, server never finds the page. If i use viewResolver works perfect, but this is not my goal.
This is my dispatcher-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.outbottle" />
<mvc:annotation-driven />
<mvc:resources mapping="/**" location="/html/" />
<!--Old code-->
<!--bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/html/"
p:suffix=".jsp" /-->
</beans>
My project structure:
And this is the controller that should handle the default request:
@Controller
public class DefaultController {
@RequestMapping(value="/", method= RequestMethod.GET)
public String index(ModelMap map) {
map.addAttribute("hello", "Hello Spring from Netbeans!!");
return "html/index.html";
}
/*Old code*/
/*@RequestMapping(value="/", method= RequestMethod.GET)
public String index(ModelMap map) {
map.addAttribute("hello", "Hello Spring from Netbeans!!");
return "index";
}*/
}
Can you please tell me what am i doing wrong? Thanks in advance!!