今天在学习《Spring+SpringMVC+MyBatis从零开始学》中遇到了一个问题,就是SpringMVC框架的@RequestMapping访问出现404,也是书上没有提到的一点。
解决方法:
1、spingmvc-config.xml添加mvc命名空间以及对应的xsi:schemaLocation
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="……
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"/>
2、添加一句配置
<mvc:annotation-driven/>
效果如图:
补充一点:如果在JSP中无法使用EL表达式,添加指令:
<%@ page isELIgnored="false" %>