提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
-
目录
1.此注解可以加在方法上,是为该方法去注册一个可以访问的路径(main.jsp创建在admin目录下的)
2.@RequestMappering注解也可以用在类上,用来区分相同路径的action方法
前言
@RequestMappering注解就是用来映射服务器访问的路径
一、SpringMVC的流程配置需求
- 使用配置文件springmvc.xml来使用框架添加前后缀(配置视图解析器,admin是创建在webapp目录下的文件夹)
-
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"> <!-- 添加包扫描--> <context:component-scan base-package="com.wsh.controller"></context:component-scan> <!-- 配置视图解析器--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!-- 配置前缀--> <property name="prefix" value="/admin/"></property> <!-- 配置后缀--> <property name="suffix" value=".jsp"></property> </bean> </beans>
- 在使用前应对DispatcherServlet进行注册以及对于.action后缀进行拦截
-
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"