说明:
     附件是项目截图及所需包截图
     此项目在tomcat,weblogic10下测试通过
配置文件
web.xml

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

index.jsp



org.springframework.web.context.ContextLoaderListener



contextConfigLocation
classpath:com/medbri/mss/config/applicationContext-*.xml



dispatcher
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:com/medbri/mss/config/applicationContext-*.xml

1


dispatcher
*.do



characterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding
GBK



characterEncodingFilter
/*



applicationContext-common.xml

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byName" default-lazy-init="true">





classpath:com/medbri/mss/config/jdbc.properties


































  
       
       
   



advice-ref="txAdvice" />
advice-ref="txAdvice" />












applicationContext-mvc.xml

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byName" default-lazy-init="true">

   

   
   
   
   
     
       
       
       
   


jdbc.properties


jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc\:oracle\:thin\:@localhost\:1521\:XE
jdbc.username=project
jdbc.password=123

mybatis-config.xml




AccountMapperController.java
@Controller
@RequestMapping("/accounts")
public class AccountMapperController{
protected static final Logger logger = Logger.getLogger(AccountMapperController.class);
protected static final Integer PAGE_SIZE = 10;
    @Inject
    private AccountMapper accountMapper;
/**
* 转向用户添加页面
* @return 返回转向信息
*/
@RequestMapping("/addUser")
public String addUser() {
return "addUser";
}
   
/**
* 添加用户
* @param acc实体
* @return 返回转向信息
*/
@RequestMapping("/add")
public String add(Account acc) {
try {
accountMapper.add(acc);
} catch (Exception e) {
e.printStackTrace();
logger.error("增加时发生异常:",e);
}
return "redirect:/accounts/queryPage.do";
}

/**
* 查询用户
* @param acc实体
* @return 返回转向信息
*/
@RequestMapping("/queryPage")
public String queryPage(Account acc,Model model) {
try {
int count =accountMapper.getCount(acc);
Pagenation pagenation=new    Pagenation(PAGE_SIZE,acc.getPageNum(),count);
acc.setStartRow(pagenation.getStartRow());
acc.setPageSize(PAGE_SIZE);
List list=accountMapper.getAllList(acc);
pagenation.setList(list);
model.addAttribute("pagenation",pagenation);
} catch (Exception e) {
e.printStackTrace();
logger.error("query时发生异常:",e);
}
return "userList";
}
}

AccountMapper.java
public interface AccountMapper extends SqlMapper {
/**
* 添加
*
* @param account
*            实体
* @throws Exception
*             抛出异常
*/
@Insert("insert into users values(seq_user_id.nextval,#{userName},#{userPassword})")
public void add(Account account) throws Exception;

/**
* 修改
*
* @param classMethod
*            mybatis配置文件里面对应的命名空间+要执行的sql语句id
* @param entity
*            封装数据的实体
* @return 返回操作结果
* @throws Exception
*             抛出所有异常
*/
@Update("update users set userName=#{userName},userPassword=#{userPassword} where userId=#{userId}")
public void edit(Account account) throws Exception;

/**
* 删除
*
* @param entity
*            封装数据的实体
* @return 返回操作结果
* @throws Exception
*             抛出所有异常
*/
@Delete("delete from users where userId=#{userId}")
public void remvoe(Account account) throws Exception;

/**
* 以id为条件查找对象
*
* @param entity
*            封装数据的实体
* @return 返回查询结果
* @throws Exception
*             抛出所有异常
*/
@Select("select t.userId,t.userName,t.userPassword from users t where t.userId=#{userId}")
public Account get(Account account) throws Exception;

/**
* 查询
*
* @param entity
*            封装数据的实体
* @return 返回查询结果
* @throws Exception
*             抛出所有异常
*/
@Select("select * from(select a.*,rownum r from(select t.userId userId,t.userName userName,t.userPassword userPassword from users t)a ) where r > #{startRow} and rownum <= #{pageSize}")
public List getAllList(Account account) throws Exception;

/**
* 查询数量
*
* @param entity
*            封装数据的实体
* @return 返回查询结果
* @throws Exception
*             抛出所有异常
*/
@Select("select count(1)from users")
public int getCount(Account account) throws Exception;
}
SqlMapper.java
public interface SqlMapper {

}