添加后,右下角会跳出提示,点击”Import Changes”完成maven依赖刷新。
或者点击Maven菜单中的刷新按钮亦可。
5.配置SpringMVC的配置文件。在WEB-INF目录下,新建一个Spring Config文件,命名为springmvc-config。
文件内容如下:
<?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
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- spring自动扫描base-pack目录下的所有Java文件,包括子目录。如果扫描到有相关注解的类,就把这些类注册为Spring的bean。 -->
<context:component-scan base-package="com.myz.controller"/>
<!-- 配置annotation类型的处理映射器,它根据请求查找映射 -->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<!-- 配置annotation类型的处理器适配器,完成对@RequestMapping标注方法的调用 -->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"/>
</beans>
<context:component-scan base-package="com.myz.controller"/>:
spring自动扫描base-pack目录下的所有Java文件,包括子目录。如果扫描到有相关注解的类,就把这些类注册为Spring的bean。
<bean/>:
配置annotation类型的处理映射器,它根据请求查找映射。
<bean/>:
配置annotation类型的处理器适配器,完成对@RequestMapping标注方法的调用
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-55466-2.html
人一身只要你努力就可以拼搏你想要的