package com.demo.controller;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.enterprise.inject.New;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import com.demo.services.UserService;
@Controller
public class UserController {
@Resource
private UserService userService;
//请求示例 后缀名可在web.xml设置
//http://127.0.0.1:8080/SSMDemo/selUser.ssm?name=123&pwd=123
/**
* 查询
* @param name
* @param pwd
* @param response
* @param request
* @throws IOException
*/
@RequestMapping(value = "selUser")
public void selUser(String name, String pwd, HttpServletResponse response,
HttpServletRequest request) throws IOException {
JSONObject jo = new JSONObject();
Map map = new HashMap();
map.put("name", name);
map.put("pwd", pwd);
jo.put("msg", "请求成功");
jo.put("result", userService.selUser(map));
jo.put("error_code", 0);
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
writer.print(jo.toString());
}
/**
* 添加
* @param name
* @param pwd
* @param response
* @param request
* @throws IOException
*/
@RequestMapping(value = "addUser")
public void addUser(String name, String pwd, HttpServletResponse response,
HttpServletRequest request) throws IOException {
JSONObject jo = new JSONObject();
Map map = new HashMap();
map.put("name", name);
map.put("pwd", pwd);
jo.put("msg", "请求成功");
jo.put("result", userService.addUser(map));
jo.put("error_code", 0);
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
writer.print(jo.toString());
}
/**
* 修改
* @param id
* @param name
* @param pwd
* @param response
* @param request
* @throws IOException
*/
@RequestMapping(value = "upUser")
public void upUser(String id,String name, String pwd, HttpServletResponse response,
HttpServletRequest request) throws IOException {
JSONObject jo = new JSONObject();
Map map = new HashMap();
map.put("name", name);
map.put("pwd", pwd);
jo.put("msg", "请求成功");
jo.put("result", userService.upUser(map));
jo.put("error_code", 0);
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
writer.print(jo.toString());
}
/**
* 删除
* @param id
* @param response
* @param request
* @throws IOException
*/
@RequestMapping(value = "delUser")
public void delUser(String id, HttpServletResponse response,
HttpServletRequest request) throws IOException {
JSONObject jo = new JSONObject();
jo.put("msg", "请求成功");
jo.put("result", userService.delUser(id));
jo.put("error_code", 0);
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
writer.print(jo.toString());
}
}
qq_30903455
- 粉丝: 1
- 资源: 2
最新资源
- 博思智联-三联集团-新乡连锁店培训流程说明.doc
- 博思智联-三联集团-职位评估培训.ppt
- 博思智联-三联集团-新乡培训流程说明.doc
- Delphi编程-Oracle-控件-delphi连接Oracle数据库控件
- mysql安装配置教程.txt
- 泛华-中国青年报项目—岗 位 描 述 书培训模搬.doc
- 和君创业—上海西域酒业项目培训—培训计划2.doc
- 和君创业—上海西域酒业项目培训—培训小结(提要)学员使用.doc
- 和君创业—上海西域酒业项目培训—业务员培训资料目录.doc
- 基于antlr4 解析器,支持spark sql, tidb sql, flink sql, Sparkflink jar 运行命令解析器详细文档+全部资料.zip
- 毕业设计:基于MQTT的物联网设备接入平台、使用Flink流处理框架详细文档+全部资料.zip
- 基于 SSM 框架,Flink 流,MySQL 数据库、BS 架构的小说网站详细文档+全部资料.zip
- 基于docker的实时监控系统,详细文档+全部资料.zip
- 基于Bilibili公开的数据,通过Flink实时分析计算,做成需要的动态图表详细文档+全部资料.zip
- IMG_20241218_182829.jpg
- 华彩--三鼎控股—华鼎锦纶子集团培训管理办法--外派培训9.27.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈