- @param account 账户
*/
@Insert(“insert into account values(#{id},#{name},#{money})”)
void insert(Account account);
}
AccountServiceImpl.java(实现类)
/**
-
@author 闲言
-
@Description 业务层实现类
-
@create 2021-02-03 12:13
*/
@Service(“accountService”)
public class AccountServiceImpl implements AccountService {
@Autowired
private AccountDao accountDao;
@Override
public Account findById(Integer id) {
return accountDao.findById(id);
}
@Override
public List findAll() {
return accountDao.findAll();
}
@Override
public void insert(Account account) {
accountDao.insert(account);
}
}
AccountDao.java(dao层接口)
/**
-
@author 闲言
-
@Description 持久层接口
-
@create 2021-02-03 12:13
*/
@Repository
public interface AccountDao {
/**
-
根据id查询
-
@param id 账户id
-
@return 账户
*/
@Select(“select * from account where id = #{id}”)
Account findById(Integer id);
/**
-
查询所有账户
-
@return 账户列表
*/
@Select("select * from account ")
List findAll();
/**
-
插入数据
-
@param account 账户
*/
@Insert(“insert into account values(#{id},#{name},#{money})”)
void insert(Account account);
}
AccountController.java(控制器)
/**
-
@author 闲言
-
@Description 账户控制器
-
@create 2021-02-03 12:26
*/
@Controller
@RequestMapping(“/account”)
public class AccountController {
@Autowired
private AccountService accountService;
/**
-
根据id查询
-
@param id
-
@return
*/
@RequestMapping(“findById”)
public ModelAndView findById(Integer id){
Account account = accountService.findById(id);
ModelAndView mv = new ModelAndView();
mv.addObject(“account”,account);
mv.setViewName(“success”);
return mv;
}
/**
-
查询所有
-
@return
*/
@RequestMapping(“findAll”)
public ModelAndView findAll(){
List accounts = accountService.findAll();
ModelAndView mv = new ModelAndView();
mv.addObject(“accounts”,accounts);
mv.setViewName(“success”);
return mv;
}
/**
-
插入Account
-
@param account
*/
@RequestMapping(“insert”)
public void insert(Account account, HttpServletResponse response) throws Exception {
accountService.insert(account);
response.setContentType(“text/json;charset=UTF-8”);
response.getWriter().write(“插入成功”);
}
}
spring.xml(spring配置文件)
<?xml version="1.0" encoding="UTF-8"?><beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:mvc=“http://www.springframework.org/schema/mvc”
xmlns:context=“http://www.springframework.org/schema/context”
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package=“cn.bloghut”>
<context:exclude-filter type=“annotation” expression=“org.springframework.stereotype.Controller”/>
</context:component-scan>
springmvc.xml(springmvc配置文件)
<?xml version="1.0" encoding="UTF-8"?><beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:mvc=“http://www.springframework.org/schema/mvc”
xmlns:context=“http://www.springframework.org/schema/context”
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package=“cn.bloghut”>
<context:include-filter type=“annotation” expression=“org.springframework.stereotype.Controller”/>
</context:component-scan>
mvc:annotation-driven/
web.xml
Archetype Created Web Application
org.springframework.web.context.ContextLoaderListener
contextConfigLocation
classpath:spring.xml
dispatcherServlet
org.springframework.web.servlet.DispatcherServlet
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
最后
笔者已经把面试题和答案整理成了面试专题文档
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
csdnimg.cn/images/e5c14a7895254671a72faed303032d36.jpg" alt=“img” style=“zoom: 33%;” />
最后
笔者已经把面试题和答案整理成了面试专题文档
[外链图片转存中…(img-RVbpbyl7-1712689812692)]
[外链图片转存中…(img-jQFUiTAj-1712689812693)]
[外链图片转存中…(img-0htrTwuw-1712689812693)]
[外链图片转存中…(img-Wwqxp5sD-1712689812694)]
[外链图片转存中…(img-0ZCGljsx-1712689812694)]
[外链图片转存中…(img-eLneWdmb-1712689812694)]
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!