本博客为这篇博客的辅助博客,主要是其中自己写的一些Demo.java代码


目录

日志的用法

Demo1.java

log4j.properties

控制反转IOC的测试

Demo2.java

applicationContext.xml1

UserService.java

UserServiceImpl.java

依赖注入

CustomerDaoImpl.java

CustomerServiceImpl.java

Demo3.java

applicationContext.xml2

依赖注入的方式2:构造方法

Car1.java

Person.java

Demo4.java

applicationContext.xml3

依赖注入方式3:p名称空间的注入(纯了解即可)

Car2.java

applicationContext.xml4

Demo4.java1

数组,集合(List,Set,Map),Properties等的注入

User.java

applicationContext.xml5

Demo4.java3

Spring框架的配置文件分开管理(了解)

applicationContext.xml

applicationContext2.xml

Demo4.java4

Spring框架整合WEB(简单的Struts整合)

CustomerDao.java

CustomerDaoImpl.java

CustomerService.java

CustomerServiceImpl.java

CustomerAction.java

struts.xml

applicationContext.xml(ZH)

导包:spring-web-4.2.4.RELEASE.jar(spring依赖包)

web.xml

固定配置:


日志的用法

Demo1.java

package com.itheima.demo1;
import org.apache.log4j.Logger;
import org.junit.Test;
/*** 演示日志用法* @author Administrator**/
public class Demo1 {//创建日志对象private Logger log=Logger.getLogger(Demo1.class);@Testpublic void run1(){System.out.println("执行了...");log.info("执行了...");}
}

log4j.properties

### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.err
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n### direct messages to file mylog.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=c\:mylog.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n### set log levels - for more verbose logging change 'info' to 'debug' ###### 在此配置文件里将inof改为off  则,所有的日志输出都会失效,就像全部被注释了一样
### 日志文件是spring依赖包里拷贝进来的,默认值就是info
log4j.rootLogger=info, stdout

控制反转IOC的测试

Demo2.java

package com.itheima.demo2;import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;/*** 测试IOC程序* @author Administrator**/
public class Demo2 {/*** 原来的方式*/@Testpublic void run1(){//创建实现类//UserServiceImpl usi = new UserServiceImpl();//usi.sayHello();UserService us=new UserServiceImpl();us.sayHello();}/*** 使用的是Spring框架的方式*/@Testpublic void run2(){//创建工厂,加载核心配置文件ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");//一读取配置文件,你配置的对象就全帮你配置完了//从工厂中获取对象   参数就写配置的id值UserService us = (UserService) ac.getBean("userService");//一般都强转为接口  写接口拓展容易  接口可以有多个实现类  都能被赋值//调用对象方法执行us.sayHello();}/*** 老的工厂版本  过时了  不推荐用* BeanFactory*/@Testpublic void run4(){//创建工厂,加载核心配置文件BeanFactory factory =new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));//从工厂中获取对象UserService us = (UserService) factory.getBean("userService");//老工厂  getBean时才会创建//调用对象的方法执行us.sayHello();    }/*** 演示销毁方法(了解)*/@Testpublic void run5(){//创建工厂,加载核心配置文件ClassPathXmlApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");//一读取配置文件,你配置的对象就全帮你配置完了//从工厂中获取对象   参数就写配置的id值UserService us = (UserService) ac.getBean("userService");//一般都强转为接口  写接口拓展容易  接口可以有多个实现类  都能被赋值//调用对象方法执行us.sayHello(); //关闭工厂 里面的对象会全部销毁ac.close();}//依赖注入 入门演示/*** 原始方式*/@Testpublic void run6_0(){//创建实现类UserServiceImpl usi = new UserServiceImpl();usi.setName("云天河");usi.sayHello();}/*** 依赖注入 : 不用set属性值  直接配置属性值*/@Testpublic void run6(){//创建工厂,加载核心配置文件ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");//一读取配置文件,你配置的对象就全帮你配置完了//从工厂中获取对象   参数就写配置的id值UserService us = (UserService) ac.getBean("userService");//一般都强转为接口  写接口拓展容易  接口可以有多个实现类  都能被赋值//调用对象方法执行us.sayHello();}}

applicationContext.xml1

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 使用bean标签 -->   <!-- class是实现类的全路径(不是接口)   id随便取的名字 --><!-- <bean id="userService" class="com.itheima.demo2.UserServiceImpl" init-method="init" destroy-method="destory"/>--><!-- init-method="init" destroy-method="destory"  (了解即可 需要用时来查 不需要记忆  只记忆重点的配置,获得对象的方式下面依赖注入的第一种方式set,这种重点)配置了之后  对象被创建时会执行javaBean中的init()方法对象被销毁时会创建javaBean中的destory()方法--><!-- 依赖注入 --><bean id="userService" class="com.itheima.demo2.UserServiceImpl"><!-- 注意name属性需要有set方法 --><property name="name" value="云天河" /><!-- 创建对象时帮你把属性辅助 --></bean></beans>

UserService.java

package com.itheima.demo2;public interface UserService {public void sayHello();
}

UserServiceImpl.java

package com.itheima.demo2;public class UserServiceImpl implements UserService {private String name;public void setName(String name) {this.name = name;}@Overridepublic void sayHello() {System.out.println("hello spring!! "+name);}//创建对象之前 框架会先调用init方法(前提配置了)public void init(){System.out.println("UserServiceImpl创建了...");}//销毁时调用此方法public void destory(){System.out.println("UserServiceImpl销毁了...");}}

依赖注入

(也是最常用的一种方式 即set属性方式)

CustomerDaoImpl.java

package com.itheima.demo3;public class CustomerDaoImpl {public void save(){System.out.println("我是持久层的dao....");}
}

CustomerServiceImpl.java

package com.itheima.demo3;public class CustomerServiceImpl {//不准new了,那么必须要提供成员属性让框架帮你封装了//提供成员属性,提供set方法  (此类需要用到dao,这就是依赖)private CustomerDaoImpl customerDao;public void setCustomerDao(CustomerDaoImpl customerDao) {this.customerDao = customerDao;}public void save() {System.out.println("我是业务层的service.....");//原始的方式//new CustomerDaoImpl().save();//spring的方式customerDao.save();}
}

Demo3.java

package com.itheima.demo3;import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Demo3 {/*** 原始方法*/@Testpublic void run1(){CustomerServiceImpl cs = new CustomerServiceImpl();cs.save();}/*** spring方式*/@Testpublic void run2(){ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");CustomerServiceImpl cs = (CustomerServiceImpl) ac.getBean("customerService");cs.save();}
}

applicationContext.xml2

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 真正演示dao的依赖注入  --><!-- set方法的注入方式是标准常用的注入方式 --><bean id="customerDaoImpl" class="com.itheima.demo3.CustomerDaoImpl"/><bean id="customerService" class="com.itheima.demo3.CustomerServiceImpl"><property name="customerDao" ref="customerDaoImpl"/></bean>     <!-- 上面的解释:首先配置了两个bean,那么框架就会帮你new相应的类对象,然后service类需要用到dao类对象,则就要将配好的dao类注入到service类里  注意注入方式是引用上面配好的bean--></beans>

依赖注入的方式2:构造方法

注意普通属性值参数用value,引用其他类对象则用ref

Car1.java

package com.itheima.demo4;public class Car1 {private String name;private Double price;//public Cart() {}//注意没有空参构造方法  配置时必须提供参数public Car1(String name, Double price) {super();this.name = name;this.price = price;}@Overridepublic String toString() {return "Car1 [name=" + name + ", price=" + price + "]";}}

Person.java

package com.itheima.demo4;public class Person {private String name;private Car1 car1;//没有内存的引用  配置时不能写value 要写refpublic Person(String name, Car1 car1) {super();this.name = name;this.car1 = car1;}@Overridepublic String toString() {return "Person [name=" + name + ", car1=" + car1 + "]";}}

Demo4.java

package com.itheima.demo4;import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Demo4 {/*** 通过构造方法实现注入   用得不多  标准用法是set方法*/@Testpublic void run1(){ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");Car1 car1=(Car1) ac.getBean("car1");System.out.println(car1);}//补上 引用的配置@Testpublic void run2(){ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");Person person=(Person) ac.getBean("person");System.out.println(person);}/*** 重复写一个set方法注入方式  以强调这是标准的注入方式*/@Testpublic void run3(){ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");Car2 car2= (Car2) ac.getBean("car2");System.out.println(car2);}}

applicationContext.xml3

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 演示构造方法的注入方式 (不常用)--><bean id="car1" class="com.itheima.demo4.Car1"><!-- 配置构造方法的参数 那么框架创建此类时就拿着参数调用对应的构造方法 --><!-- <constructor-arg name="name" value="奇瑞QQ"/><constructor-arg name="price" value="35000"/> --><!-- 另一种配置参数的方式   index="0"表示第一个构造参数  ="1"表示第二个构造参数--><constructor-arg index="0" value="奇瑞QQ2"/><constructor-arg index="1" value="50000"/></bean><bean id="person" class="com.itheima.demo4.Person"><constructor-arg name="name" value="天河"/><constructor-arg name="car1" ref="car1"/><!-- 注意引用类实例 不能写value--></bean>    <!-- 重复演示set方法注入方式 --><bean id="car2" class="com.itheima.demo4.Car2"><property name="name" value="飞车"/><property name="price" value="99999"/></bean></beans>

依赖注入方式3:p名称空间的注入(纯了解即可)

Car2.java

package com.itheima.demo4;public class Car2 {private String name;private Double price;public String getName() {return name;}public void setName(String name) {this.name = name;}public Double getPrice() {return price;}public void setPrice(Double price) {this.price = price;}//方法多了没事  少了不行@Overridepublic String toString() {return "Car2 [name=" + name + ", price=" + price + "]";}}

applicationContext.xml4

<?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:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 采用p名称空间的方式注入(了解)  引入名称空间时为了避免同名属性冲突,去了别名p 下面也要加上别名p:--><!-- <bean id="car2" class="com.itheima.demo4.Car2" p:name="保时捷" p:price="1000"/> --><!-- 一行即可 也很简单 --><!-- SpEL表达式方式注入 --><bean id="car2" class="com.itheima.demo4.Car2"><property name="name" value="#{'飞车2'}"/><property name="price" value="#{99999}"/></bean><!-- 这种方式的好处没演示出来  可以直接像el表达式一样用'.'调用属性 --></beans>

Demo4.java1

@Testpublic void run3(){ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");Car2 car2= (Car2) ac.getBean("car2");System.out.println(car2);}

数组,集合(List,Set,Map),Properties等的注入

自己写的不多,但是三大框架整合时需要用到这些配置

User.java

package com.itheima.demo4;import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;public class User {private String[] arrs;public void setArrs(String[] arrs) {this.arrs = arrs;}private List<String> list;public void setList(List<String> list) {this.list = list;}private Map<String, String> map;public void setMap(Map<String, String> map) {this.map = map;}private Properties pro;//java.utils包下的  属性文件类public void setPro(Properties pro) {this.pro = pro;}@Overridepublic String toString() {return "User [arrs=" + Arrays.toString(arrs) + ", list=" + list+ ", map=" + map + ", pro=" + pro + "]";}
}

applicationContext.xml5

<?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:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 注入集合 --><bean id="user" class="com.itheima.demo4.User"><property name="arrs"><!-- 数组或者集合的值需要在list子标签里配置了 --><list><value>天河</value><value>紫英</value><value>梦璃</value><value>菱纱</value></list></property><property name="list"><list><value>玄霄</value><value>天青</value><value>夙玉</value><!-- <ref="person"/>   同样list中放的是对象的时候value换成ref--></list></property><!-- set集合配置是 <list>改成<set> --><property name="map"><map><!-- key是对象时用key-ref   value是对象时用value-ref --><entry key="a" value="苹果"/>  <entry key="b" value="香蕉"/>  </map></property><!-- 属性文件类也只是一个普通的属性 配置没太多特殊 直接在这里写属性文件的内容罢了 --><property name="pro"><props><prop key="username">root</prop><prop key="password">1234</prop></props></property></bean></beans>

Demo4.java3

package com.itheima.demo4;import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Demo4 {  /*** 测试注入集合*/@Testpublic void run4(){ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");User user= (User) ac.getBean("user");System.out.println(user);}}

Spring框架的配置文件分开管理(了解)

applicationContext.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:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 注入集合 --><!-- <bean id="user" class="com.itheima.demo4.User"><property name="arrs">数组或者集合的值需要在list子标签里配置了<list><value>天河</value><value>紫英</value><value>梦璃</value><value>菱纱</value></list></property><property name="list"><list><value>玄霄</value><value>天青</value><value>夙玉</value><ref="person"/>   同样list中放的是对象的时候value换成ref</list></property>set集合配置是 <list>改成<set><property name="map"><map>key是对象时用key-ref   value是对象时用value-ref<entry key="a" value="苹果"/>  <entry key="b" value="香蕉"/>  </map></property>属性文件类也只是一个普通的属性 配置没太多特殊 直接在这里写属性文件的内容罢了<property name="pro"><props><prop key="username">root</prop><prop key="password">1234</prop></props></property></bean> --><!-- 配置文件写多个(多写集合从配置文件) 分模块写 方便管理 但是要在主配置文件中引入从配置文件   --><import resource="applicationContext2.xml"/><!-- 同一个目录下直接写相对路径  在某个包写要加完整包名  com/itheima/xxx/applicationContext2.xml 和struts一样 --></beans>

applicationContext2.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:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 注入集合 --><bean id="user" class="com.itheima.demo4.User"><property name="arrs"><!-- 数组或者集合的值需要在list子标签里配置了 --><list><value>天河</value><value>紫英</value><value>梦璃</value><value>菱纱</value></list></property><property name="list"><list><value>玄霄</value><value>天青</value><value>夙玉</value><!-- <ref="person"/>   同样list中放的是对象的时候value换成ref--></list></property><!-- set集合配置是 <list>改成<set> --><property name="map"><map><!-- key是对象时用key-ref   value是对象时用value-ref --><entry key="a" value="苹果"/>  <entry key="b" value="香蕉"/>  </map></property><!-- 属性文件类也只是一个普通的属性 配置没太多特殊 直接在这里写属性文件的内容罢了 --><property name="pro"><props><prop key="username">root</prop><prop key="password">1234</prop></props></property></bean></beans>

Demo4.java4

package com.itheima.demo4;import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Demo4 {/*** 测试配置文件分模块管理*/@Testpublic void run4(){ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");User user= (User) ac.getBean("user");System.out.println(user);}/*** 可以直接加载多个多个配置文件  此时就不必在主配置文件中引入其他配置文件了* 但是要是真的有多个配置文件 还是建议引入而不写这种代码 (倾向于在配置文件中写)*/@Testpublic void run5(){ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml","applicationContext2.xml");User user= (User) ac.getBean("user");System.out.println(user);}}

Spring框架整合WEB(简单的Struts整合)

主要解决apllication.xml配置文件如何只加载一次的问题

先搭建struts2环境(核心过滤器别忘了),再搭建spring最简单的环境(6个包)

CustomerDao.java

package com.itheima.dao;public interface CustomerDao {public void save();
}

CustomerDaoImpl.java

package com.itheima.dao;import com.itheima.service.CustomerService;public class CustomerDaoImpl implements CustomerService{@Overridepublic void save() {System.out.println("持久层:保存客户...");}}

CustomerService.java

package com.itheima.service;public interface CustomerService {public void save();
}

CustomerServiceImpl.java

package com.itheima.service;import com.itheima.dao.CustomerDaoImpl;public class CustomerServiceImpl implements CustomerService {private CustomerDaoImpl customerDao;public void setCustomerDao(CustomerDaoImpl customerDao) {this.customerDao = customerDao;}@Overridepublic void save() {System.out.println("业务层:保存客户...");customerDao.save();}}

CustomerAction.java

package com.itheima.web.action;import javax.servlet.ServletContext;import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;import com.itheima.service.CustomerService;
import com.opensymphony.xwork2.ActionSupport;/*** 客户的Action* @author Administrator**/
public class CustomerAction extends ActionSupport{//spring学完后 实战之前  将所有博客和代码读一遍  复习一下下  最好有个小总结 简单复习而已 不要苛求什么/*** 保存客户* @return*/public String save(){System.out.println("WEB层保存客户...");/*//使用工厂  这样写每次请求action都会加载一次配置文件,也即都会创建一个工厂,很明显这不合适  这个时候就需要整合操作了ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");CustomerService cs= (CustomerService) ac.getBean("customerService");cs.save();return NONE;*//*** 那么需要导包 spring-web...  然后监听ServletContext类(最大的全局共享域)* 这个类是在服务器开启时创建,关闭时销毁* 有个专门的监听器是监听这个类的创建和销毁的* * 过程如下:启动服务器->ServletContext对象被创建->ServletContext监听器对象方法执行->在监听器里执行加载配置文件的代码*                  ->那么配置文件只会加载一次,里面所有的类对象也都创建好了* * spring-web-4.2.4.RELEASE.jar包里就有监听器 配置一下即可*///解决方案:需要使用web的工厂方式//action里获得servletContext有个好值栈啊ServletContext servletContext = ServletActionContext.getServletContext();//获得web工厂WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);//利用web工厂获得对象CustomerService cs= (CustomerService)context.getBean("customerService");cs.save();return NONE;}
}

struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN""http://struts.apache.org/dtds/struts-2.3.dtd"><struts><!-- 包结构   包名随便取 但是不能相同--><package name="crm" namespace="/" extends="struts-default"><action name="customer_*" class="com.itheima.web.action.CustomerAction" method="{1}"/><!--{1}取得是前面name属性中第1个*  --></package></struts>

applicationContext.xml(ZH)

<?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:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 配置客户的业务层 --><bean id="customerService" class="com.itheima.service.CustomerServiceImpl"><property name="customerDao" ref="customerDao"/></bean><!-- 配置客户的dao --><bean id="customerDao" class="com.itheima.dao.CustomerDaoImpl"/></beans>

导包:spring-web-4.2.4.RELEASE.jar(spring依赖包)

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_2_5.xsd" id="WebApp_ID" version="2.5"><display-name>day35_crm</display-name><!-- 配置web整合的监听器(最原始的Listener) --><listener><!-- 此监听器默认情况下只能加载WEB-INF目录下的配置文件 --><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- 提供配置方式,让他加载src目录下的配置文件(配置一个指定的全局参数) --><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><!-- 核心过滤器千万别忘记了 --><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping><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>
</web-app>

固定配置:

<!-- 配置web整合的监听器(最原始的Listener) --><listener><!-- 此监听器默认情况下只能加载WEB-INF目录下的配置文件 --><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- 提供配置方式,让他加载src目录下的配置文件(配置一个指定的全局参数) --><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><!-- struts2核心过滤器千万别忘记了 --><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping>

spring_day01 demo代码相关推荐

  1. Java框架JSON-RPC项目demo代码实战 + JAVA WEB配置虚拟目录(转自21天java web开发)

    Java框架JSON-RPC项目demo代码实战 备注  JAVA WEB配置虚拟目录(转自21天java web开发) https://blog.csdn.net/wjxbj/article/det ...

  2. WP7开发—Silverlight多点触摸事件详解【含Demo代码】

    最近在学习WP7的Silverlight编程,就把学习到知识点整理为日志,方便自己理解深刻点,也作为笔记和备忘,如有不合理或者错误之处,还恳请指正. WP7的支持多点触摸,有两种不同的编程模式: 1. ...

  3. 免费资源 | ActiveReports 报表控件发布多平台 Demo 代码集合

    近期,ActiveReports 产品开发组的小伙伴针对大家比较关注的报表功能.常见问题.经典实现,特意准备了一个Demo代码集合,涉及WinFormss \ ASP.NET \ MVC 多个技术平台 ...

  4. 超轻量级DI容器框架Google Guice与Spring框架的区别教程详解及其demo代码片段分享...

    超轻量级DI容器框架Google Guice与Spring框架的区别教程详解及其demo代码片段分享 DI框架 Google-Guice入门介绍 转载于:https://www.cnblogs.com ...

  5. java中thread实例_Java多线程并发执行demo代码实例

    主类:MultiThread,执行并发类 package java8test; import java.util.ArrayList; import java.util.List; import ja ...

  6. TCC Demo 代码实现

    TCC Demo 代码实现 简介     设计实现一个 TCC 分布式事务框架的简单 Demo,实现事务管理器,不需要实现全局事务的持久化和恢复.高可用等 工程运行 工程地址:TCCDemo      ...

  7. Android 后台发送邮件 (收集应用异常信息+Demo代码)

    Android 后台发送邮件 (收集应用异常信息+Demo代码) 参考文章: (1)Android 后台发送邮件 (收集应用异常信息+Demo代码) (2)https://www.cnblogs.co ...

  8. RAD Studio 10 自带Demo代码汇总说明

    来源:https://www.cnblogs.com/findumars/p/5149128.html 大家好,好多朋友来信咨询Delphi和C++Builder的移动开发.DataSnap架构等问题 ...

  9. demo代码目录整理

    文章目录 Demo代码 介绍 码云地址 Qt代码 Qxlsx报表测试代码 QPainter+QPrinter报表测试代码 tcpClient tcp客户端demo 百度地图调用demo 9宫格图案手势 ...

最新文章

  1. C语言 函数(做个笔记)
  2. 判断数字是否在区间 python实现
  3. html div剩下高度设置,使div填充剩余屏幕空间的高度
  4. 大牛书单 | 大数据存储方向好书分享
  5. 人体识别_电子皮肤用于人体状态识别的柔性集成传感器
  6. 程序员的传奇“破圈”之路
  7. 路由交换笔记(27)--ACL访问控制列表之练习
  8. Merge the incoming changes into the current branch
  9. python绘制动态心电图_可穿戴设备中测心电图这样功能能达到医用标准吗?未来前景如何?在医用和便携之间是否还有市场?...
  10. FileUpload上传过大文件异常
  11. MATLAB绘图 最大化全屏后保存
  12. CVPR 2021 Exploring Simple Siamese Representation Learning
  13. Ubuntu 20.04 server乌班图服务器部署django,uwsgi,mysql,nginx细节
  14. 搭建gos_Gos ast Package pt 1的好东西
  15. EasyExcel自定义表头
  16. 生死看淡,不服就GAN(五)----用DCGAN生成MNIST手写体
  17. 如何推广企业微信号?企业进行公众号的推广有哪些方法?
  18. 【第2篇】基础数据类型
  19. iPhone4 iOS 5.1.1 越狱之后必装的插件
  20. 会计学原理学习笔记——第三章——账户与复式记账(3.4生产准备业务核算——材料采购业务核算)

热门文章

  1. PopuoWindow 弹出框
  2. Micosoft Visual C++ Runtime Library Runtime Error! Program: E:\UserschenliqunAnaconda3\python.exe
  3. git missing change-id解决办法
  4. 你刷我,我刷你,霸榜CLUE甜蜜蜜
  5. 1643: 【入门】行李托运费-2
  6. linux系统下创建anaconda新环境及问题解决
  7. C# 实现窗口程序winform像QQ一样靠近桌面边缘自动隐藏窗口
  8. 手把手教你作者python机器人,自己训练一个机器人助手
  9. 自己搞个chatgpt机器人
  10. SEO并不难学,我是如何学习好SEO的