spring mvc:基于MVC思想的应用框架的快速入门( 四 )
至此spring+mybatis就在web中整合完毕了 , 还剩下spring.mvc , 它不需要整合 , 只需要将springmvc.xml拿过来 , 然后再web.xml中配置好前端控制器就好了
springmvc org.springframework.web.servlet.DispatcherServlet
一套完整的流程
浏览器访问 , 处理器进行处理 , 去servic层 , service层去dao层 , dao层查询数据库 , 获取数据之后 , 返回service , 然后返回控制层 , 最终到jsp页面 , 这就是基本的web开发逻辑
首先application.xml,springmvc.xml,sqlMapConfig.xml、web.xml的四个文件的配置
application.xml
sqlMapConfig.xml
package com.huanfeng.ssm.controller; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.HttpRequestHandler; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import com.huanfeng.ssm.pojo.Items; import com.huanfeng.ssm.pojo.QueryVo; import com.huanfeng.ssm.service.ItemService; @Controller public class ItemController { @Autowired private ItemService itemService; @RequestMapping(valuehttp://news.hoteastday.com/a/= ''/item/itemlist.action'') public ModelAndView itemList(){ //从Mysql中查询 List
Service层
package com.huanfeng.ssm.service; import java.util.Date; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.huanfeng.ssm.dao.ItemsMapper; import com.huanfeng.ssm.pojo.Items; @Service public class ItemServiceImpl implements ItemService { @Autowired private ItemsMapper itemsMapper; //查询商品列表 public List
- 华为发布首个基于5G MEC云边端协同的工业视觉解决方案
- 嘻哈飞车族腻害,高人都是这样玩SpringBoot整合RabbitMQ
- 上海市浦东模范中学|[浦东]浦东模范中学:“基于素养培育 构建四适课堂”浦兴学区语文主题研讨活动
- 行业互联网华为发布首个基于5G MEC云边端协同的工业视觉解决方案
- 上海市浦东新区竹园小学|[浦东]竹园小学:基于标准 落实要求 均衡导向 集群发展-学校沪东校区接受浦东新区小学沪东学区化课程与教学调研纪实
- 和讯名家 苹果在赌什么?
- 和讯名家苹果在赌什么?
- 柠檬少年CHCC2020干货 | 达实智能杨雪来:基于物联网技术的达实智慧医院整体解决方案
- 英特尔|英特尔披露基于Ice Lake微架构Xeon处理器的安全新特性
- 行业互联网贸泽电子与BittWare签订全球分销协议 分销基于英特尔和Xilinx FPGA的加速卡
