的web.xml和用SpringMVC url-pattern的
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/*.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
控制器
@Controller
@RequestMapping("/car/*")
public class CarController extends BaseController {
@RequestMapping("baojia.html")
public ModelAndView baojia() {
ModelAndView view = new ModelAndView();
view.setViewName("baojia");
return view;
}
當我訪問http://mydomain/car/baojia.html並有此錯誤:
[carloan]2016-04-21 09:01:31,177 WARN [org.springframework.web.servlet.PageNotFound] - <No mapping found for HTTP request with URI [/views/baojia.jsp] in DispatcherServlet with name 'springMVC'>
spring.xml的ViewResolver
<bean id="ViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="cache" value="false"/>
<property name="contentType" value="text/html;charset=UTF-8" />
<property name="prefix" value="/views/"/>
<property name="suffix" value=".jsp"/>
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
</bean>
和我有/views/boajia.jsp文件
是否我的作家,它不工作
<mvc:resources mapping="/views/" location="/views/**" />
,我有一個問題,我wan't這個URL模式匹配:/ API/* 和控制器是:
@Controller
@RequestMapping("/api/*")
public class CarApiController extends BaseController {
@RequestMapping("get")
@ResponseBody
public JsonResult getCars()
但它不能正常工作
我TRID 「/汽車/」 ,但它不能工作 – EricLin