标签:link sheet ica tno har mod ring attribute ons
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> <link href="${pageContext.request.contextPath}/static/css/application.css" rel="stylesheet"> <script src="${pageContext.request.contextPath}/static/js/application.js"></script> <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.0.js"></script> </head> <body> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="myTag" tagdir="/WEB-INF/tags" %> <table width="70%" align="center"> <tr> <td colspan=4><a href="${pageContext.request.contextPath}/toCart">查看购物车</a></td> </tr> <c:set var="num" value="0"></c:set> <c:forEach var="m" items="${page.result}"> <c:if test="${num==0}"> <tr> </c:if> <td> <a href="${pageContext.request.contextPath}/toGoodsDesc/${m.uuid}"> <table> <tr> <td><img src="${pageContext.request.contextPath}/static/images/logo.jpg"/></td> <td>${m.description }</td> </tr> <tr> <td>${m.name }</td> </tr> </table> </a> </td> <c:set var="num" value="${num+1}"></c:set> <c:if test="${num==3}"> <c:set var="num" value="0"></c:set> </tr> </c:if> </c:forEach> </table> </body> </html>
关于Goods的控制器
package com.sishuok.architecture1.goodsmgr.web; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import com.sishuok.architecture1.goodsmgr.service.IGoodsService; import com.sishuok.architecture1.goodsmgr.vo.GoodsModel; import com.sishuok.architecture1.goodsmgr.vo.GoodsQueryModel; import com.sishuok.pageutil.Page; import com.sishuok.util.format.DateFormatHelper; import com.sishuok.util.json.JsonHelper; @Controller @RequestMapping(value="/goods") public class GoodsController { @Autowired private IGoodsService iservice = null; @RequestMapping(value="toAdd",method=RequestMethod.GET) public String toAdd(){ return "goods/add"; } @RequestMapping(value="add",method=RequestMethod.POST) public String add(@ModelAttribute("m") GoodsModel m){ iservice.create(m); return "goods/success"; } @RequestMapping(value="toUpdate/{uuid}",method=RequestMethod.GET) public String toUpdate(Model model,@PathVariable("uuid") int uuid){ GoodsModel m = iservice.getByUuid(uuid); model.addAttribute("m", m); return "goods/update"; } @RequestMapping(value="update",method=RequestMethod.POST) public String post(@ModelAttribute("m") GoodsModel m){ iservice.update(m); return "goods/success"; } @RequestMapping(value="toDelete/{uuid}",method=RequestMethod.GET) public String toDelete(Model model,@PathVariable("uuid") int uuid){ GoodsModel m = iservice.getByUuid(uuid); model.addAttribute("m", m); return "goods/delete"; } @RequestMapping(value="delete",method=RequestMethod.POST) public String post(@RequestParam("uuid") int uuid){ iservice.delete(uuid); return "goods/success"; } @RequestMapping(value="toList",method=RequestMethod.GET) public String toList(@ModelAttribute("wm")GoodsWebModel wm,Model model){ GoodsQueryModel qm = null; if(wm.getQueryJsonStr()==null || wm.getQueryJsonStr().trim().length()==0){ qm = new GoodsQueryModel(); }else{ String s = wm.getQueryJsonStr(); s = s.replace("-", "%"); qm = (GoodsQueryModel)JsonHelper.str2Object(s, GoodsQueryModel.class); } qm.getPage().setNowPage(wm.getNowPage()); if(wm.getPageShow() > 0){ qm.getPage().setPageShow(wm.getPageShow()); } Page dbPage = iservice.getByConditionPage(qm); // model.addAttribute("wm", wm); model.addAttribute("page", dbPage); return "goods/list"; } @RequestMapping(value="toQuery",method=RequestMethod.GET) public String toQuery(){ return "goods/query"; } }
Java高级架构师(一)第28节:Index、商品详细页和购物车
标签:link sheet ica tno har mod ring attribute ons
原文地址:https://www.cnblogs.com/sunrunzhi/p/10175487.html