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());
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
免费Spring+SpringMVC+Mybatis框架整合例子(SSM)支持跨域
共79个文件
jar:53个
xml:7个
class:3个
需积分: 50 46 下载量 6 浏览量
2017-09-01
17:58:37
上传
评论
收藏 15.44MB ZIP 举报
温馨提示
1.spring MVC + spring +mybatis,是标准的MVC设计模式,将整个系统划分为显示层,Controller层,Service层,DAO层四层使用Spring MVC负责请求的转发和视图管理spring实现业务对象管理,mybatis作为数据对象的持久化引擎。 2.Spring是一个开源框架,Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架,还能更好的让其他框架整合。 3.Spring MVC框架是有一个MVC框架,通过实现Model-View-Controller模式来很好地将数据、业务与展现进行分离。 4.MyBatis 是一个基于Java的持久层框架
资源推荐
资源详情
资源评论
收起资源包目录
SSMDemo.zip (79个子文件)
demo.sql 800B
SSMDemo
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 414B
org.eclipse.core.resources.prefs 57B
org.eclipse.wst.common.component 480B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 522B
org.eclipse.jdt.core.prefs 364B
src
spring-mybatis.xml 3KB
jdbc.properties 98B
com
demo
orm
IUser.java 250B
IUser.xml 917B
controller
UserController.java 4KB
services
UserService.java 1KB
.project 1KB
WebRoot
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 3KB
classes
spring-mybatis.xml 3KB
jdbc.properties 98B
com
demo
orm
IUser.class 365B
IUser.xml 917B
controller
UserController.class 3KB
services
UserService.class 1KB
springMVC-servlet.xml 706B
lib
log4j-core-2.0-rc1.jar 686KB
commons-collections-3.1.jar 546KB
activation.jar 55KB
ezmorph-1.0.6.jar 84KB
slf4j-log4j12-1.7.7.jar 9KB
commons-logging-1.0.4.jar 37KB
dom4j-1.6.1.jar 307KB
spring-context-support-4.0.2.RELEASE.jar 132KB
mysql-connector-java-5.1.7-bin.jar 693KB
commons-beanutils-1.7.0.jar 184KB
httpcore-4.3.2.jar 276KB
aopalliance-1.0.jar 4KB
mybatis-spring-1.2.1.jar 48KB
slf4j-api-1.7.7.jar 29KB
mail.jar 363KB
spring-jdbc-4.0.2.RELEASE.jar 410KB
org.aspectj.aspectjweaver_1.6.0.v200805211800.jar 1.81MB
spring-aop-4.0.2.RELEASE.jar 344KB
spring-instrument-tomcat-4.0.2.RELEASE.jar 10KB
mybatis-3.2.0.jar 684KB
spring-web-4.0.2.RELEASE.jar 649KB
spring-jms-4.0.2.RELEASE.jar 206KB
spring-build-src-4.0.2.RELEASE.jar 71KB
spring-websocket-4.0.2.RELEASE.jar 254KB
spring-webmvc-portlet-4.0.2.RELEASE.jar 171KB
java-property-utils-1.9.jar 8KB
spring-oxm-4.0.2.RELEASE.jar 78KB
spring-instrument-4.0.2.RELEASE.jar 7KB
commons-dbcp-1.2.1.jar 105KB
spring-core-4.0.2.RELEASE.jar 938KB
spring-aspects-4.0.2.RELEASE.jar 51KB
spring-beans-4.0.2.RELEASE.jar 653KB
httpclient-4.3.5.jar 577KB
struts2-spring-plugin-2.3.1.2.jar 21KB
commons-logging.jar 54KB
spring-orm-4.0.2.RELEASE.jar 358KB
spring-framework-bom-4.0.2.RELEASE.jar 6KB
commons-pool-1.2.jar 41KB
xmlbeans-2.3.0.jar 2.54MB
spring-tx-4.0.2.RELEASE.jar 242KB
spring-test-4.0.2.RELEASE.jar 437KB
spring-webmvc-4.0.2.RELEASE.jar 645KB
commons-io-2.2.jar 170KB
json-lib-2.1.jar 122KB
commons-lang-2.3.jar 240KB
spring-context-4.0.2.RELEASE.jar 951KB
gson-2.3.1.jar 206KB
log4j-1.2.17.jar 478KB
log4j-api-2.0-rc1.jar 113KB
spring-expression-4.0.2.RELEASE.jar 200KB
cors-filter-1.7.jar 25KB
spring-messaging-4.0.2.RELEASE.jar 235KB
commons-fileupload-1.3.1.jar 67KB
index.jsp 829B
.classpath 1KB
共 79 条
- 1
资源评论
qq_30903455
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功