package com.hdzz.web;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.hdzz.service.MarketService;
import com.hdzz.service.ShopService;
/**
* Servlet implementation class ShopService
*/
@WebServlet("/ShopService")
public class ShopServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private ShopService ms = new ShopService();
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String state = request.getParameter("state");
if(state.equals("getAdd")) {
//查询购物车添加信息(传一个id)。http://localhost:8080/market/shop?state=getAdd&3
this.getAdd(request,response);
}else if(state.equals("getDelete")){
this.getDelete(request, response);
//删除购物车商品(传要 删除的id)。http://localhost:8080/market/shop?state=getDelete&1
}else if(state.equals("getAlter")){
this.getAlter(request, response);
//(传一个优惠卷面值和对应的id)http://localhost:8080/market/shop?state=getAlter&20&1
}else if(state.equals("getSearch")){
this.getSearch(request, response);
//查询购物车商品。http://localhost:8080/market/shop?state=getSearch
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void getAdd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/** 设置后台跨域 */
response.setContentType("text/html;charset=utf-8");
response.setHeader("Access-Control-Allow-Origin", "*");
//获取url后面所带的参数得到的是个字符串
String value=request.getQueryString();
// 将url后面的字符串按指定字符转化成数组
String[] valueArray = value.split("&");
// for (String values : valueArray) {
// System.out.println(values);
// }
System.out.println(valueArray[1]);
//将url中取出的数据将格式转为中文
String id=java.net.URLDecoder.decode(valueArray[1],"UTF-8");
String returnJson = ms.getAddByJson(id);
response.getWriter().print(returnJson);
// response.getOutputStream().write((returnJson).getBytes());
}
protected void getDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/** 设置后台跨域 */
response.setContentType("text/html;charset=utf-8");
response.setHeader("Access-Control-Allow-Origin", "*");
//获取url后面所带的参数得到的是个字符串
String value=request.getQueryString();
// 将url后面的字符串按指定字符转化成数组
String[] valueArray = value.split("&");
// for (String values : valueArray) {
// System.out.println(values);
// }
System.out.println(valueArray[1]);
//将url中取出的数据将格式转为中文
String id=java.net.URLDecoder.decode(valueArray[1],"UTF-8");
String returnJson = ms.getDeleteByJson(id);
response.getWriter().print(returnJson);
// response.getOutputStream().write((returnJson).getBytes());
}
protected void getAlter(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/** 设置后台跨域 */
response.setContentType("text/html;charset=utf-8");
response.setHeader("Access-Control-Allow-Origin", "*");
//获取url后面所带的参数得到的是个字符串
String value=request.getQueryString();
// 将url后面的字符串按指定字符转化成数组
String[] valueArray = value.split("&");
// for (String values : valueArray) {
// System.out.println(values);
// }
System.out.println(valueArray[1]);
//将url中取出的数据将格式转为中文
String id=java.net.URLDecoder.decode(valueArray[1],"UTF-8");
String price=java.net.URLDecoder.decode(valueArray[2],"UTF-8");
String returnJson = ms.getAlterByJson(price,id);
response.getWriter().print(returnJson);
// response.getOutputStream().write((returnJson).getBytes());
}
protected void getSearch(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/** 设置后台跨域 */
response.setContentType("text/html;charset=utf-8");
response.setHeader("Access-Control-Allow-Origin", "*");
String returnJson = ms.getSearchByJson();
response.getWriter().print(returnJson);
// response.getOutputStream().write((returnJson).getBytes());
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
个人花大量时间整理出的真实毕业设计实战成果,内容丰富,文档也很详细。无论做毕业设计还是用于学习技能,或工作中当做参考资料,都能发挥重要作用 亲们下载我任何一个付费资源后,即可私信联系我免费下载其他相关资源哦~ 个人花大量时间整理出的真实毕业设计实战成果,内容丰富,文档也很详细。无论做毕业设计还是用于学习技能,或工作中当做参考资料,都能发挥重要作用 亲们下载我任何一个付费资源后,即可私信联系我免费下载其他相关资源哦~ 个人花大量时间整理出的真实毕业设计实战成果,内容丰富,文档也很详细。无论做毕业设计还是用于学习技能,或工作中当做参考资料,都能发挥重要作用 亲们下载我任何一个付费资源后,即可私信联系我免费下载其他相关资源哦~
资源推荐
资源详情
资源评论
收起资源包目录
《毕业设计》--小程序网上商城,我的毕业设计,类似京东.zip (180个子文件)
Market.class 4KB
Shop.class 4KB
BaseDao.class 4KB
ShopServlet.class 3KB
MarketServlet.class 3KB
ShopService.class 3KB
MarketService.class 2KB
DaoTestShop.class 1KB
DaoTest.class 1KB
.classpath 922B
org.eclipse.wst.common.component 462B
org.eclipse.wst.jsdt.ui.superType.container 49B
.gitignore 145B
mysql-connector-java-5.1.37-bin.jar 963KB
gson-2.2.4.jar 186KB
ShopServlet.java 4KB
MarketServlet.java 4KB
BaseDao.java 3KB
Market.java 3KB
Shop.java 3KB
ShopService.java 2KB
MarketService.java 1KB
DaoTest.java 887B
DaoTestShop.java 610B
details.js 6KB
cart.js 5KB
index.js 3KB
ListMode.js 2KB
search.js 2KB
more.js 2KB
index.js 2KB
index.js 2KB
index.js 1KB
index.js 1KB
prodType.js 1KB
app.js 1KB
ucenter.js 884B
http.js 857B
index.js 766B
http-p.js 651B
index.js 585B
index.js 477B
index.js 473B
index.js 421B
split.js 104B
config.js 2B
.jsdtscope 491B
app.json 1KB
project.config.json 1KB
index.json 167B
prodType.json 121B
index.json 94B
settings.json 87B
more.json 75B
search.json 75B
jsconfig.json 74B
cart.json 71B
details.json 48B
index.json 48B
index.json 48B
index.json 48B
index.json 46B
index.json 46B
index.json 46B
ucenter.json 43B
index.json 41B
index.json 23B
MANIFEST.MF 36B
org.eclipse.wst.jsdt.ui.superType.name 6B
bg.png 215KB
1.png 134KB
2.png 117KB
21.png 108KB
14.png 105KB
19.png 105KB
3.png 100KB
15.png 83KB
16.png 78KB
5.png 73KB
4.png 69KB
18.png 58KB
8.png 51KB
6.png 47KB
7.png 45KB
17.png 37KB
11.png 28KB
13.png 22KB
9.png 21KB
20.png 17KB
10.png 17KB
beishang.png 16KB
12.png 10KB
my.png 5KB
edit.png 5KB
app.png 5KB
31.png 4KB
shop.png 4KB
30.png 4KB
prodtype.png 3KB
51.png 3KB
共 180 条
- 1
- 2
资源评论
季风泯灭的季节
- 粉丝: 696
- 资源: 2920
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功