我有一个非常基本的spring mvc web应用程序设置。这是我的web.xml映射如下:
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
和spring-config.xml
<mvc:default-servlet-handler/>
<mvc:annotation-driven />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<context:component-scan base-package="cz.dmostek"/>
<context:annotation-config/>
这是我的jsp页面的目录结构
`-- web
`-- WEB-INF
|-- pages
| |-- css
| | |-- foundation.css
| | `-- normalize.css
| |-- images
| |-- index.jsp
| `-- js
`-- web.xml
我的控制器在下面声明:
@Controller
public class TestController {
@RequestMapping(value = "/")
public String
return "index";
}
}
但是,当我尝试访问localhost时:8080 / app /我收到404错误。在日志中我有2013-10-19 16:12:09,326 () DEBUG DispatcherServlet - Successfully completed request
如果我调试应用程序似乎一切正常,控制器被调用,视图被渲染,但我仍然得到404.你怎么看?