摘要:
阅读全文
摘要:
默认为singleton,prototype会在调用getBean()方法时,也就是第一次真正用到bean时才会实例化。所谓容器启动时指的是:ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");这句代码执行时。=========bean.xml=========<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframewor 阅读全文
摘要:
===============PersonServiceBeanFactory.java===============package blog.service.impl; public class PersonServiceBeanFactory { public static PersonServiceBean createPersonServiceBean(){ return new PersonServiceBean(); } public PersonServiceBean createPersonServiceBean2(){ return new PersonSe... 阅读全文
摘要:
案例:先加入dom4j的jar包。====================BlogClassPathXMLApplicationContext.java====================package junit.test; import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;. 阅读全文
摘要:
==================DBUtil.java:==================package blog.util; import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; import javax.naming.Context;
import javax.naming.InitialContext;
import javax.nami... 阅读全文
摘要:
====================DBUtil.java:====================package blog.util; import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; import javax.naming.Context;
import javax.naming.InitialContext;
import javax.... 阅读全文
摘要:
package blog; import java.sql.*;
import java.util.Properties; import blog.exception.DBException;
import blog.util.DBUtil; public class AddStudentDao implements IAddStudentDao { @Override public boolean addStudent(AddStudentForm studentForm) { //使用JDBC操作数据 Co... 阅读全文
摘要:
=================UserdaoImpl.java:=================packageblog.dao.impl; importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.PreparedStatement;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.sql.Statement;
importjava.util.ArrayList;
importjava.util.List; im... 阅读全文
摘要:
====================CharacterEncodingFilter.java====================packageblog.filter; importjava.io.IOException; importjavax.servlet.Filter;
importjavax.servlet.FilterChain;
importjavax.servlet.FilterConfig;
importjavax.servlet.ServletException;
importjavax.servlet.ServletRequest;
importjavax.... 阅读全文
摘要:
/*首先必须加入log4j的jar包。*/=============log4j.properties=============# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
# For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
log4j.rootLogger=debug,stdout,fileout ### Validation ###
#log4.. 阅读全文
摘要:
案例:PersonService.java:package blog.service; public interface PersonService { public abstract void save(); }PersonServiceBean.java:package blog.service.impl; import blog.service.PersonService; public class PersonServiceBean implements PersonService { public void save(){ System.out.println(... 阅读全文
摘要:
手动实现: 阅读全文