考慮以下Controller
沒有映射發現的Index.html
@Controller
public class HomeController {
@RequestMapping(value="/")
public ModelAndView home() {
ModelAndView model = new ModelAndView("index");
return model;
}
這是我servlet-context.xml
:
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".html" />
</bean>
這是我web.xml
:
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
每次我點擊網址我收到此消息:
Aug 08, 2015 10:59:47 PM org.springframework.web.servlet.PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI [/MeraComputer/WEB-INF/views/index.html] in DispatcherServlet with name 'appServlet' Aug 08, 2015 10:59:48 PM org.springframework.web.servlet.PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI [/MeraComputer/WEB-INF/views/index.html] in DispatcherServlet with name 'appServlet'
我的文件夾結構也不錯,我想,
顯示您的應用程序的樹結構 –
單擊文件夾結構鏈接..您將會看到... – anonymous
可能是這個文件'servlet-context.xml'的東西 – ACV