今天任务:配置好SSM框架的四个配置文件和新学一个知识叫Bootstrap并将他引入maven中。
Bootstrap:http://www.bootcss.com/
第二天:https://blog.csdn.net/qq_43296599/article/details/85075236
关于maven项目引入css或者js文件 路径的问题:
https://blog.csdn.net/qq_43296599/article/details/85097525
1、SSM框架的四个配置文件:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>ssm-studentInfoManager</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
<!-- 配置中央前端控制器:DispatcherServlet -->
<servlet>
<!-- 这里的springmvc名字需要和的springmvc配置文件名一致 -->
<servlet-name>springmvc</servlet-name>
<!-- 中央前端控制器 -->
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<!-- 和上面的name名字一致 -->
<servlet-name>springmvc</servlet-name>
<!-- "/"表拦截所有请求 -->
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- 容器监听器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<!-- spring.xml路径 -->
<param-value>classpath*:spring.xml</param-value>
</context-param>
<listener>
<!-- 容器监听器路径 -->
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 字符编码过滤器(写在所有过滤器的前面) -->
<filter>
<filter-name>encodingFilter</filter-name>
<!-- 字符编码过滤器 -->
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<!-- 设置初始化值 -->
<init-param>
<!-- 字符编码初始化 -->
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<!-- 请求初始化 -->
<param-name>forceRequestEncoding</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<!-- 响应初始化 -->
<param-name>forceResponseEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<!-- 拦截所有 -->
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
springmvc-servlet.xml
<?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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
<!-- 开启注解并扫描指定包 -->
<context:component-scan base-package="com.fhx.controller"></context:component-scan>
<!-- 配置视图资源解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- property属性,配置前缀和后缀 -->
<property name="prefix" value="/WEB-INF/pages/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "mybatis-3-config" "mybatis-3-config.dtd" >
<configuration>
<!-- 别名 -->
<typeAliases>
<!-- 扫描指定路径下的所有实体类 -->
<package name="com.fhx.pojo"/>
</typeAliases>
</configuration>
spring.xml
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
<!-- 配置数据源:BasicDataSource -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<!-- 配置四个属性分别为:加载驱动、连接数据库、用户名、密码 -->
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url"
value="jdbc:mysql://localhost:3306/studentinfomanager"></property>
<property name="username" value="root"></property>
<property name="password" value="520"></property>
</bean>
<!-- 配置事务管理:DataSourceTransactionManager -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 引用数据源 -->
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 配置工厂容器SqlSession -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 引用数据源 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 配置config.xml路径 -->
<property name="configLocation" value="classpath:config.xml"></property>
<!-- 扫描指定路径下的所有实体映射文件 -->
<property name="mapperLocations" value="classpath*:com/fhx/mapper/*.xml"></property>
</bean>
<!-- 扫描实体映射文件 -->
<bean id="scannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 指定扫描的包 -->
<property name="basePackage" value="com.fhx.mapper"></property>
</bean>
</beans>
2、Bootstrap: