我有一个使用注解进行请求映射的控制器类,但是当我尝试将浏览器连接到它时似乎无法识别
当我尝试使用网址http://localhost:8088/carMart连接时 我收到错误: 原始服务器找不到目标资源的当前表示,或者不愿意透露其存在。
控制器类:
package com.store.controller
@Controller
public class CarMartController {
@RequestMapping("/carMart")
public String navigateToCarMart( ModelMap model) {
return "carMart";
}
}
web.xml
<description>
Configuration file for the Store Application
</description>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/store-servlet.xml</param-value>
</context-param>
<servlet>
<servlet-name>store</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>store</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
store-servlet.xml:
<context:component-scan base-package = "com.store" />
<context:annotation-config/>
<bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name = "prefix" value = "/WEB-INF/jsp/" />
<property name = "suffix" value = ".jsp" />
</bean>
<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/"/>
<mvc:resources mapping="/jquery/**" location="/jquery/"/>
<import resource="/spring/store.xml" />
<import resource="/hibernate/hibernate-configuration.xml" />
我为RequestMapping尝试了各种组合,但始终存在相同的问题,还尝试将基本包设置为com.store.controller,但仍然存在相同的错误