springMVC 的实现
来源:互联网 发布:java变量 编辑:程序博客网 时间:2024/05/16 01:50
<?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-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<!--
spring类扫描
在 base-package 的包以及子包进行类扫描(但是类要标上component 注解)
-->
<context:component-scan base-package="com.xiaoke"></context:component-scan>
</beans>
PersonDao.java
package com.xiaoke.Dao;
import com.xiaoke.model.Person;
public interface PersonDao {
/**
* 保存人员
*/
public void savaPerson(Person person);
}
PersonService.java
package com.xiaoke.Service;
import com.xiaoke.model.Person;
public interface PersonService {
/**
* 保存人员
*/
public void savaPerson(Person person);
}
PersonServiceImpl.java
package com.xiaoke.Service.Impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.xiaoke.Dao.PersonDao;
import com.xiaoke.Service.PersonService;
import com.xiaoke.model.Person;
//@Component("personService") //这个是通用的,功能跟@Service() @Controller("personAction") 是一样的
@Service("personService")
public class PersonServiceImpl implements PersonService {
@Resource
private PersonDao personDao;
/**
* 保存人员
*/
public void savaPerson(Person person){
personDao.savaPerson(person);
}
}
PersonAction.java
package com.xiaoke.Action;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.xiaoke.Service.PersonService;
import com.xiaoke.model.Person;
//@Component("personAction") //这个是通用的,功能跟@Service() @Controller("personAction") 是一样的
@Controller("personAction")
@Scope("prototype") //改为多例
public class PersonAction {
@Resource
private PersonService personService;
/**
* 保存人员
*/
public void savaPerson(Person person){
personService.savaPerson(person);
}
}
- springmvc国际化的实现
- springMVC的简单实现
- springMVC 的实现
- SpringMVC的HelloWorld实现
- SpringMVC的JSON实现
- SpringMVC的实现原理
- springmvc--登录的实现
- 【springmvc】SpringMVC 实现json的输入
- 【springmvc】springmvc实现日志的监听 log4j
- 【springmvc】springmvc实现接口的开发
- SpringMVC特别的实现类
- 基于SpringMVC实现的RESTFul
- springMVC中ehcache的实现
- SpringMVC下的kindeditor实现
- 基于SpringMVC的HelloWorld实现
- springMVC的Restful接口实现
- SpringMVC拦截器的实现
- SpringMVC Ehcache的缓存实现
- android设计值得收藏的网站
- SSDB主从配置
- 保護你的隱私,從 PGP 開始!
- Windows安装Apache后的一些设置
- leetcode 1: Two Sum
- springMVC 的实现
- Android拍照得到的照片旋转了90度
- std::bind1st与std::bind2nd的区别
- Centos 简单的安全设置
- 分布式系统应用现状
- SpringMVC在Tomcat下报异常
- 主动通知Android系统图库进行更新
- 打印一个集合的幂集C++实现
- Unix Ware平台上SIGCLD重复发送解决办法