I have two files index.html and user.jsp, there location is WebContent/WEB-INF/.
In addition, i am able to access user.jsp with the following code:
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
</bean>
Controller code:
@RequestMapping(value="/usertimepass",method=RequestMethod.GET)
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ModelAndView time(){
ModelAndView mv=new ModelAndView();
mv.setViewName("user");
System.out.println("returned user");
return mv;
}
However, i am unable to access index.html with the following revamped code:
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".html" />
</bean>
Controller code:
@RequestMapping(value="/usertimepass",method=RequestMethod.GET)
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ModelAndView time(){
ModelAndView mv=new ModelAndView();
mv.setViewName("index");
System.out.println("returned index");
return mv;
}
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SampleApp</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
Thanks!!