package cn.pw.ssm.controller;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletOutputStream;
import org.apache.commons.io.FileUtils;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
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 org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import cn.pw.ssm.constrant.Const;
import cn.pw.ssm.pojo.Standard;
import cn.pw.ssm.service.StandardService;
import cn.pw.ssm.util.PageBean;
import cn.pw.ssm.util.PageSupport;
@Controller
public class StandardController {
@Autowired
private StandardService standardService;
@RequestMapping("/index")
public String index() {
return "index";
}
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
@RequestMapping(value="/x")
public String x() {
return "x";
}
@RequestMapping(value="/draw")
public String draw() {
return "draw";
}
@RequestMapping(value="/ppt")
public String ppt() {
return "ppt";
}
@RequestMapping(value="/schedule")
public String schedule() {
return "schedule";
}
@RequestMapping(value="/word")
public String word() throws IOException {
Runtime.getRuntime().exec("notepad.exe");
return "x";
}
@RequestMapping(value="/list")
public String list(@RequestParam(name="queryCondition",required=false) String queryCondition,
@RequestParam(name="pageIndex",defaultValue="1") String pageIndex,Model model) {
PageBean<Standard> standards=standardService.getStandardList(queryCondition, Integer.parseInt(pageIndex));
model.addAttribute("standards", standards);
model.addAttribute("queryCondition", queryCondition);
return "list";
}
@RequestMapping(value="/add")
public String add() {
return "add";
}
@RequestMapping(value="judge")
@ResponseBody
public boolean judgeStandard(String stdNum) {
return standardService.haveStandardStdNum(stdNum);
}
@RequestMapping(value="save",method=RequestMethod.POST)
public String save(Standard standard,@RequestParam MultipartFile packagePath,HttpServletRequest request) {
try {
if(!packagePath.isEmpty()) {
String pathName=request.getSession().getServletContext().getRealPath(File.separatorChar+Const.UPLOAD_PATH);
String fileName=packagePath.getOriginalFilename();
String fileEx=fileName.substring(fileName.lastIndexOf("."),fileName.length());
fileName=System.currentTimeMillis()+fileEx;
File destFile=new File(pathName+File.separatorChar+fileName);
FileUtils.copyInputStreamToFile(packagePath.getInputStream(), destFile);
standard.setPackagePath(fileName);
}
if(standardService.saveStandard(standard)) {
request.getSession().setAttribute("hint", "增加成功");
}else {
request.getSession().setAttribute("hint", "增加失败");
}
} catch (Exception e) {
e.printStackTrace();
request.getSession().setAttribute("hint", "增加失败");
}
return "redirect:list";
}
@RequestMapping(value="/{id}/update",method=RequestMethod.GET)
public String update(@PathVariable int id,HttpServletRequest request) {
Standard standard=standardService.getStandardById(id);
request.setAttribute("standard", standard);
return "update";
}
@RequestMapping(value="update",method=RequestMethod.POST)
public String update(Standard standard,@RequestParam MultipartFile pic,HttpServletRequest request) {
try {
if(!pic.isEmpty()) {
String pathName=request.getSession().getServletContext().getRealPath(File.separatorChar+Const.UPLOAD_PATH);
String fileName=pic.getOriginalFilename();
String fileEx=fileName.substring(fileName.lastIndexOf("."),fileName.length());
fileName=System.currentTimeMillis()+fileEx;
File destFile=new File(pathName+File.separatorChar+fileName);
FileUtils.copyInputStreamToFile(pic.getInputStream(), destFile);
standard.setPackagePath(fileName);
}
if(standardService.updateStandard(standard)) {
request.getSession().setAttribute("hint", "修改成功");
}else {
request.getSession().setAttribute("hint", "修改失败");
}
} catch (Exception e) {
e.printStackTrace();
request.getSession().setAttribute("hint", "增加失败");
}
return "redirect:list";
}
@RequestMapping(value="delete/{id}")
public String delete(@PathVariable int id,HttpServletRequest request) {
if(standardService.deleteStandard(id)) {
request.getSession().setAttribute("hint", "删除成功");
}else {
request.getSession().setAttribute("hint", "删除失败");
}
return "redirect:../list";
}
PageSupport page=new PageSupport();
@RequestMapping(value="/excel")
public void excel(HttpServletResponse response) throws IOException{
response.setCharacterEncoding("UTF-8");
List<Standard> list = standardService.queryExcelInfo();
System.out.println(list); //创建excel文件
HSSFWorkbook wb = new HSSFWorkbook(); //创建sheet页
HSSFSheet sheet = wb.createSheet("项目表"); //创建标题行
HSSFRow titleRow = sheet.createRow(0);
titleRow.createCell(0).setCellValue("项目号");
titleRow.createCell(1).setCellValue("名称");
titleRow.createCell(2).setCellValue("类型");
titleRow.createCell(3).setCellValue("状态");
titleRow.createCell(4).setCellValue("开始时间");
titleRow.createCell(5).setCellValue("完成时间");
for (Standard standard: list) {
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum()+1);
dataRow.createCell(0).setCellValue(standard.getStdNum());
dataRow.createCell(1).setCellValue(standard.getZhName());
dataRow.createCell(2).setCellValue(standard.getWords());
dataRow.createCell(3).setCellValue(standard.getVersion());
dataRow.createCell(4).setCellValue(standard.getReleaseDate());
dataRow.createCell(5).setCellValue(standard.getImplDate());
}
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="
+ new String("Project".getBytes(),"iso-8859-1") + ".xls");
OutputStream ouputStream = response.getOutputStream();
wb.write(ouputStream);
ouputStream.flush();
ouputStream.close();
}
public static void main(String[] args) {
System.out.println("ok");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
完整的javaSSM管理系统项目实例ssm.zip
共224个文件
jar:40个
class:38个
java:38个
需积分: 49 42 下载量 83 浏览量
2020-08-18
13:35:32
上传
评论 7
收藏 25.39MB ZIP 举报
温馨提示
实用Mysql数据库的一个项目,含文本上传,图片上传回显,导出excel功能,bootstrap前端框架,ssm对应的lib的各种jar文件等,只需自行在数据库里建表,需要tomcat启动
资源推荐
资源详情
资源评论
收起资源包目录
完整的javaSSM管理系统项目实例ssm.zip (224个子文件)
StandardController.class 10KB
CustomerController.class 9KB
AccountController.class 8KB
EntityController.class 8KB
StaffController.class 8KB
GoodsController.class 8KB
BusinessController.class 8KB
StandardServiceImpl.class 3KB
CustomerServiceImpl.class 3KB
BusinessServiceImpl.class 3KB
AccountServiceImpl.class 3KB
EntityServiceImpl.class 3KB
GoodsServiceImpl.class 3KB
StaffServiceImpl.class 3KB
PageSupport.class 3KB
PageBean.class 3KB
Staff.class 2KB
Account.class 2KB
Standard.class 2KB
Entity.class 2KB
Customer.class 2KB
Goods.class 2KB
Business.class 2KB
StandardMapper.class 772B
CustomerMapper.class 771B
BusinessMapper.class 770B
AccountMapper.class 764B
EntityMapper.class 757B
GoodsMapper.class 750B
StaffMapper.class 748B
StandardService.class 623B
CustomerService.class 622B
BusinessService.class 621B
AccountService.class 610B
EntityService.class 598B
GoodsService.class 586B
StaffService.class 584B
Const.class 396B
.classpath 887B
org.eclipse.wst.common.component 540B
org.eclipse.wst.jsdt.ui.superType.container 49B
bootstrap.css 124KB
easyui.css 74KB
font-awesome.css 26KB
font-awesome.min.css 21KB
style.css 16KB
icon.css 2KB
x.css 1KB
fontawesome-webfont.eot 55KB
poi-ooxml-schemas-3.9.jar 4.49MB
poi-3.9.jar 1.78MB
aspectjweaver.jar 1.77MB
jackson-databind-2.7.4.jar 1.15MB
spring-context-4.3.4.RELEASE.jar 1.08MB
spring-core-4.3.4.RELEASE.jar 1.06MB
poi-ooxml-3.9.jar 915KB
spring-webmvc-4.3.4.RELEASE.jar 892KB
spring-web-4.3.4.RELEASE.jar 795KB
spring-beans-4.3.4.RELEASE.jar 743KB
mybatis-3.2.2.jar 683KB
spring-test-4.3.4.RELEASE.jar 582KB
mysql-connector-java-5.1.0-bin.jar 553KB
log4j-1.2.16.jar 470KB
spring-orm-4.3.4.RELEASE.jar 466KB
spring-jdbc-4.3.4.RELEASE.jar 417KB
jstl-1.2.jar 405KB
standard.jar 384KB
spring-messaging-4.3.4.RELEASE.jar 372KB
spring-aop-4.3.4.RELEASE.jar 371KB
spring-jms-4.3.4.RELEASE.jar 282KB
spring-tx-4.3.4.RELEASE.jar 261KB
spring-expression-4.3.4.RELEASE.jar 257KB
jackson-core-2.7.4.jar 247KB
spring-context-support-4.3.4.RELEASE.jar 183KB
commons-io-2.4.jar 181KB
spring-webmvc-portlet-4.3.4.RELEASE.jar 173KB
commons-dbcp-1.2.2.jar 119KB
aspectjrt.jar 114KB
spring-oxm-4.3.4.RELEASE.jar 83KB
commons-pool-1.3.jar 61KB
commons-logging-1.1.1.jar 59KB
jboss-logging-3.1.0.GA.jar 59KB
commons-fileupload-1.2.2.jar 58KB
spring-aspects-4.3.4.RELEASE.jar 57KB
jackson-annotations-2.7.4.jar 50KB
mybatis-spring-1.2.0.jar 48KB
spring-instrument-tomcat-4.3.4.RELEASE.jar 10KB
spring-instrument-4.3.4.RELEASE.jar 7KB
aopalliance.jar 4KB
StandardController.java 8KB
CustomerController.java 7KB
AccountController.java 6KB
EntityController.java 6KB
BusinessController.java 6KB
StaffController.java 6KB
GoodsController.java 6KB
StandardServiceImpl.java 3KB
CustomerServiceImpl.java 3KB
BusinessServiceImpl.java 3KB
AccountServiceImpl.java 3KB
共 224 条
- 1
- 2
- 3
资源评论
qq_3081447939
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功