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";
}
}
posted on 2019-06-15 13:41  段苏这些  阅读(103)  评论(0编辑  收藏  举报