当前位置:网站首页>Simple case of SSM framework
Simple case of SSM framework
2022-07-07 05:34:00 【_ Xiao Xu_】
By the end ssm A simple case is made after the framework , Realize simple addition, deletion, modification and search .
Project structure chart :
See project structure :
Key code :
The front is jsp technology , You can also use it vue Separate your choice .
Order page :
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page isELIgnored="false" %>
<%@include file="./common/head.jsp"%>
<div class="right">
<div class="location">
<strong> Your current position is :</strong>
<span> Order management page </span>
</div>
<div class="search">
<form method="get" action="${pageContext.request.contextPath }/jsp/bill.do">
<input name="method" value="query" class="input-text" type="hidden">
<span> Name of commodity :</span>
<input name="queryProductName" type="text" value="${queryProductName }">
<span> supplier :</span>
<select name="queryProviderId">
<c:if test="${providerList != null }">
<option value="0">-- Please select --</option>
<c:forEach var="provider" items="${providerList}">
<option value="${provider}">${
provider}</option>
</c:forEach>
</c:if>
</select>
<span> Whether to pay :</span>
<select name="queryIsPayment">
<option value="0">-- Please select --</option>
<option value="1" ${
queryIsPayment == 1 ? "selected=\"selected\"":"" }> Unpaid </option>
<option value="2" ${
queryIsPayment == 2 ? "selected=\"selected\"":"" }> Paid </option>
</select>
<input value=" check Inquiry " type="submit" id="searchbutton">
<a href="${pageContext.request.contextPath }/billadd"> Add order </a>
</form>
</div>
<!-- Billing form Styles are common to suppliers -->
<table class="providerTable" cellpadding="0" cellspacing="0">
<tr class="firstTr">
<th width="10%"> Order number </th>
<th width="20%"> Name of commodity </th>
<th width="10%"> supplier </th>
<th width="10%"> Order amount </th>
<th width="10%"> Whether to pay </th>
<th width="10%"> Creation time </th>
<th width="30%"> operation </th>
</tr>
<c:forEach var="bill" items="${billList }" varStatus="status">
<tr>
<td>
<span>${
bill.billCode }</span>
</td>
<td>
<span>${
bill.productName }</span>
</td>
<td>
<span>${
bill.providerId}</span>
</td>
<td>
<span>${
bill.totalPrice}</span>
</td>
<td>
<span>
<c:if test="${bill.isPayment == 1}"> Unpaid </c:if>
<c:if test="${bill.isPayment == 2}"> Paid </c:if>
</span>
</td>
<td>
<span>
${
bill.creationDate}
</span>
</td>
<td>
<span><a class="viewBill" href="${pageContext.request.contextPath }/billview?code=${bill.billCode}" billid=${
bill.id } billcc=${
bill.billCode }><img src="${pageContext.request.contextPath }/images/read.png" alt=" see " title=" see "/></a></span>
<span><a class="modifyBill" href="${pageContext.request.contextPath }/billmodify?code=${bill.billCode}" billid=${
bill.id } billcc=${
bill.billCode }><img src="${pageContext.request.contextPath }/images/xiugai.png" alt=" modify " title=" modify "/></a></span>
<span><a class="deleteBill" href="javascript:deleteBill();" billid=${
bill.id } billcc=${
bill.billCode }><img src="${pageContext.request.contextPath }/images/schu.png" alt=" Delete " title=" Delete "/></a></span>
</td>
</tr>
</c:forEach>
</table>
</div>
</section>
<!-- Click the delete button to pop up the page -->
<div class="zhezhao"></div>
<div class="remove" id="removeBi">
<div class="removerChid">
<h2> Tips </h2>
<div class="removeMain">
<p> Are you sure you want to delete this order ?</p>
<a href="#" id="yes"> determine </a>
<a href="#" id="no"> Cancel </a>
</div>
</div>
</div>
<%@include file="./common/foot.jsp" %>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/billlist.js"></script>
The interface is not as good-looking as the one above , The framework downloads itself .
Supplier page :
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="./common/head.jsp"%>
<div class="right">
<div class="location">
<strong> Your current position is :</strong>
<span> Supplier management page </span>
</div>
<div class="search">
<form method="get" action="${pageContext.request.contextPath }/provider.select">
<input name="method" value="query" type="hidden">
<span> Supplier code :</span>
<input name="queryProCode" type="text" value="${queryProCode }">
<span> Name of supplier :</span>
<input name="queryProName" type="text" value="${queryProName }">
<input value=" check Inquiry " type="submit" id="searchbutton">
<a href="${pageContext.request.contextPath }/jsp/provideradd.jsp"> Add supplier </a>
</form>
</div>
<!-- Supplier operation form -->
<table class="providerTable" cellpadding="0" cellspacing="0">
<tr class="firstTr">
<th width="10%"> Supplier code </th>
<th width="20%"> Name of supplier </th>
<th width="10%"> Contacts </th>
<th width="10%"> contact number </th>
<th width="10%"> Fax </th>
<th width="10%"> Creation time </th>
<th width="30%"> operation </th>
</tr>
<c:forEach var="provider" items="${providerList }" varStatus="status">
<tr>
<td>
<span>${provider.proCode }</span>
</td>
<td>
<span>${provider.proName }</span>
</td>
<td>
<span>${provider.proContact}</span>
</td>
<td>
<span>${provider.proPhone}</span>
</td>
<td>
<span>${provider.proFax}</span>
</td>
<td>
<span>
${provider.creationDate}
</span>
</td>
<td>
<span><a class="viewProvider" href="${pageContext.request.contextPath }/providerview?code=${provider.proCode}" proid=${provider.id } proname=${provider.proName }><img src="${pageContext.request.contextPath }/images/read.png" alt=" see " title=" see "/></a></span>
<span><a class="modifyProvider" href="${pageContext.request.contextPath }/provideralter?code=${provider.proCode}" proid=${provider.id } proname=${provider.proName }><img src="${pageContext.request.contextPath }/images/xiugai.png" alt=" modify " title=" modify "/></a></span>
<span><a class="deleteProvider" href="javascript:;" proid=${provider.id } proname=${provider.proName }><img src="${pageContext.request.contextPath }/images/schu.png" alt=" Delete " title=" Delete "/></a></span>
</td>
</tr>
</c:forEach>
</table>
</div>
</section>
<!-- Click the delete button to pop up the page -->
<div class="zhezhao"></div>
<div class="remove" id="removeProv">
<div class="removerChid">
<h2> Tips </h2>
<div class="removeMain" >
<p> Are you sure you want to delete this supplier ?</p>
<a href="#" id="yes"> determine </a>
<a href="#" id="no"> Cancel </a>
</div>
</div>
</div>
<%@include file="./common/foot.jsp" %>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/providerlist.js"></script>
It is mainly the interaction part of the front and back end , All controllers are controlled by spring Container control , Pay attention to releasing static resources .
Order background :
package cms.ssm.controller;
import cms.ssm.dao.BillMapper;
import cms.ssm.dao.ProviderMapper;
import cms.ssm.model.Bill;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@Controller
public class BillController {
@Resource
private BillMapper billMapper;
@Resource
private ProviderMapper providerMapper;
@GetMapping("/bill")
public String showBill(Model model){
List<Bill> bills = billMapper.selectAll();
List<String> list = providerMapper.selectProviderNames();
model.addAttribute("billList",bills);
model.addAttribute("providerList",list);
return "/jsp/billlist.jsp";
}
@GetMapping("/billview")
public String showOne(@RequestParam("code") String code,Model model){
Bill bill = billMapper.selectByCode(code);
model.addAttribute("bill",bill);
return "/jsp/billview.jsp";
}
@GetMapping("/billmodify")
public String alterBill(@RequestParam("code") String code,Model model){
Bill bill = billMapper.selectByCode(code);
List<String> list = providerMapper.selectProviderNames();
model.addAttribute("bill",bill);
model.addAttribute("provider",list);
return "/jsp/billmodify.jsp";
}
@GetMapping(value = "/jsp/bill.do")
public String select_more(@RequestParam("method") String method,@RequestParam("queryProductName") String queryProductName,@RequestParam("queryIsPayment") int queryIsPayment,Model model){
List<Bill> billList = billMapper.selectMore("%"+queryProductName+"%", queryIsPayment);
model.addAttribute("billList",billList);
return "/jsp/billlist.jsp";
}
@GetMapping(value = "/billadd")
public String billAdd(Model model){
List<String> list = providerMapper.selectProviderNames();
model.addAttribute("list",list);
return "/jsp/billadd.jsp";
}
@RequestMapping(value = "/billadd.do", method = RequestMethod.GET)
public void billAddColumn(@RequestParam("billCode") String billCode, @RequestParam("productName") String productName, @RequestParam("productCount") Double productCount,@RequestParam("productUnit") String productUnit,@RequestParam("providerId") int providerId){
Bill bill =new Bill();
bill.setBillCode(billCode);
bill.setProductName(productName);
bill.setProductCount(productCount);
bill.setProductUnit(productUnit);
bill.setProviderId(providerId);
billMapper.insertOneBill(bill);
}
}
Supplier background :
package cms.ssm.controller;
import cms.ssm.dao.ProviderMapper;
import cms.ssm.dao.UserMapper;
import cms.ssm.model.Provider;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
@Controller
public class ProviderController {
@Resource
private ProviderMapper providerMapper;
// @Resource
// private UserMapper userMapper;
@GetMapping(value = "/provider")
public String showProviders(Model model){
List<Provider> list= providerMapper.selectAll();
//List<String> roles= userMapper.select_all_role();
model.addAttribute("providerList",list);
return "jsp/providerlist.jsp";
}
@GetMapping(value = "/providerview")
public String providerView(@RequestParam("code") String code,Model model){
Provider provider= providerMapper.selectById(code);
model.addAttribute("provider",provider);
return "/jsp/providerview.jsp";
}
@GetMapping(value = "/provideralter")
public String providerAlter(@RequestParam("code") String code,Model model){
Provider provider= providerMapper.selectById(code);
model.addAttribute("provider",provider);
return "/jsp/providermodify.jsp";
}
@GetMapping(value = "/provider.select")
public String providerSelect(Model model,@RequestParam("queryProCode") String queryProCode,@RequestParam("queryProName") String queryProName){
List<Provider> list = providerMapper.selectMore("%"+queryProCode+"%", "%"+queryProName+"%");
model.addAttribute("providerList",list);
return "/jsp/providerlist.jsp";
}
@GetMapping(value = "/provideradd.do")
public String providerAdd(@RequestParam("proCode") String proCode,@RequestParam("proName") String proName,@RequestParam("proContact") String proContact,@RequestParam("proPhone") String proPhone,@RequestParam("proAddress") String proAddress,@RequestParam("proFax") String proFax,@RequestParam("proDesc") String proDesc){
Provider provider = new Provider();
provider.setProCode(proCode);
provider.setProName(proName);
provider.setProContact(proContact);
provider.setProPhone(proPhone);
provider.setProAddress(proAddress);
provider.setProFax(proFax);
provider.setProDesc(proDesc);
providerMapper.insertOne(provider);
return "/jsp/provideradd.jsp";
}
@GetMapping(value = "/provider.oparater")
@ResponseBody
public String providerOparater(@RequestParam("proid") int id){
providerMapper.delById(id);
String delResult = "true";
return delResult;
}
}
Only some codes are referenced
边栏推荐
- JVM (19) -- bytecode and class loading (4) -- talk about class loader again
- 利用OPNET进行网络指定源组播(SSM)仿真的设计、配置及注意点
- MySQL数据库学习(8) -- mysql 内容补充
- 漏电继电器JD1-100
- 【js组件】自定义select
- ssm框架的简单案例
- Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface
- 什么是依赖注入(DI)
- Is the human body sensor easy to use? How to use it? Which do you buy between aqara green rice and Xiaomi
- Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
猜你喜欢
京东商品详情页API接口、京东商品销量API接口、京东商品列表API接口、京东APP详情API接口、京东详情API接口,京东SKU信息接口
Annotation初体验
JVM(十九) -- 字节码与类的加载(四) -- 再谈类的加载器
1. AVL tree: left-right rotation -bite
Torch optimizer small parsing
5. 数据访问 - EntityFramework集成
LabVIEW is opening a new reference, indicating that the memory is full
Flink SQL realizes reading and writing redis and dynamically generates hset key
Digital innovation driven guide
JVM(二十) -- 性能监控与调优(一) -- 概述
随机推荐
高压漏电继电器BLD-20
论文阅读【Sensor-Augmented Egocentric-Video Captioning with Dynamic Modal Attention】
《5》 Table
K6el-100 leakage relay
Taobao commodity details page API interface, Taobao commodity list API interface, Taobao commodity sales API interface, Taobao app details API interface, Taobao details API interface
Phenomenon analysis when Autowired annotation is used for list
Let f (x) = Σ x^n/n^2, prove that f (x) + F (1-x) + lnxln (1-x) = Σ 1/n^2
JVM (XX) -- performance monitoring and tuning (I) -- Overview
MySQL数据库学习(8) -- mysql 内容补充
4. Object mapping Mapster
Leetcode (417) -- Pacific Atlantic current problem
Where is NPDP product manager certification sacred?
Life experience of an update statement
删除文件时提示‘源文件名长度大于系统支持的长度’无法删除解决办法
导航栏根据路由变换颜色
Dbsync adds support for mongodb and ES
论文阅读【Open-book Video Captioning with Retrieve-Copy-Generate Network】
ssm框架的简单案例
数字化创新驱动指南
Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game