首页 > 其他 > 详细

maven构建SSM工程[应用]4

时间:2019-06-15 15:16:22      阅读:97      评论:0      收藏:0      [点我收藏+]
5.Service
5.1创建接口
public interface ItemsService {
public Items findById(Integer id);
}

 5.2实现这里使用的是注解加配置文件的方式,最后把注解一起写下来

@Service
@Transactional
public class ItemsServiceImpl implements ItemsService {
@Autowired
private ItemsDao itemsDao;

public Items findById(Integer id) {
return itemsDao.findById(id);
}
}
6.web层
@Controller
@RequestMapping("/items")
public class ItemsController {
@Autowired
private ItemsService itemsService;

@RequestMapping("/showDetail")
public String showDetail(Model model){
Items items = itemsService.findById(1);
model.addAttribute("item",items);
return "itemDetail";
}
}

maven构建SSM工程[应用]4

原文:https://www.cnblogs.com/duansuzhexie/p/11027349.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!