Java高级架构师(一)第13节:Spring MVC实现Web层开发
package com.sishuok.architecture1.customermgr.web; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
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 com.sishuok.architecture1.customermgr.service.ICustomerService;
import com.sishuok.architecture1.customermgr.vo.CustomerModel;
import com.sishuok.architecture1.customermgr.vo.CustomerQueryModel;
import com.sishuok.pageutil.Page;
import com.sishuok.util.format.DateFormatHelper;
import com.sishuok.util.json.JsonHelper; @Controller
@RequestMapping(value="/customer")
public class CustomerController {
@Autowired
private ICustomerService ics = null; @RequestMapping(value="toAdd",method=RequestMethod.GET)
public String toAdd(){ return "customer/add";
}
@RequestMapping(value="add",method=RequestMethod.POST)
public String add(@ModelAttribute("cm") CustomerModel cm){
cm.setRegisterTime(DateFormatHelper.long2str(System.currentTimeMillis()));
ics.create(cm);
return "customer/success";
}
@RequestMapping(value="toUpdate/{customerUuid}",method=RequestMethod.GET)
public String toUpdate(Model model,@PathVariable("customerUuid") int customerUuid){
CustomerModel cm = ics.getByUuid(customerUuid);
model.addAttribute("cm", cm);
return "customer/update";
}
@RequestMapping(value="update",method=RequestMethod.POST)
public String post(@ModelAttribute("cm") CustomerModel cm){
ics.update(cm);
return "customer/success";
}
@RequestMapping(value="toDelete/{customerUuid}",method=RequestMethod.GET)
public String toDelete(Model model,@PathVariable("customerUuid") int customerUuid){
CustomerModel cm = ics.getByUuid(customerUuid);
model.addAttribute("cm", cm);
return "customer/delete";
}
@RequestMapping(value="delete",method=RequestMethod.POST)
public String post(@RequestParam("uuid") int customerUuid){
ics.delete(customerUuid);
return "customer/success";
}
@RequestMapping(value="toList",method=RequestMethod.GET)
public String toList(@ModelAttribute("wm")CustomerWebModel wm,Model model){
CustomerQueryModel cqm = null;
if(wm.getQueryJsonStr()==null || wm.getQueryJsonStr().trim().length()==0){
cqm = new CustomerQueryModel();
}else{
cqm = (CustomerQueryModel)JsonHelper.str2Object(wm.getQueryJsonStr(), CustomerQueryModel.class);
} cqm.getPage().setNowPage(wm.getNowPage());
if(wm.getPageShow() > 0){
cqm.getPage().setPageShow(wm.getPageShow());
} Page dbPage = ics.getByConditionPage(cqm); //
model.addAttribute("wm", wm);
model.addAttribute("page", dbPage); return "customer/list";
}
@RequestMapping(value="toQuery",method=RequestMethod.GET)
public String toQuery(){
return "customer/query";
}
}
Java高级架构师(一)第13节:Spring MVC实现Web层开发的更多相关文章
- Java高级架构师(一)第01节:整体课程概览
本课程专注于构建:高可扩展性.高性能.大数据量.高并发.分布式的系统架构. 从零开始.全面系统.成体系的软件架构课程,循序渐进的讲述构建上述系统架构所需要的各种技术知识和技能. 适应人群: 1:有一定 ...
- 好好讲一讲,到底什么是Java高级架构师!
一. 什么是架构师 曾经有这么个段子: 甲:我已经应聘到一家中型软件公司了,今天上班的时候,全公司的人都来欢迎我. 乙:羡慕ing,都什么人来了? 甲:CEO.COO.CTO.All of 程序员,还 ...
- JAVA高级架构师基础功:Spring中AOP的两种代理方式:动态代理和CGLIB详解
在spring框架中使用了两种代理方式: 1.JDK自带的动态代理. 2.Spring框架自己提供的CGLIB的方式. 这两种也是Spring框架核心AOP的基础. 在详细讲解上述提到的动态代理和CG ...
- Java高级架构师(一)第42节:应用上Nginx过后的体系结构
以后的架构思考方向: 体系结构的演变
- Java高级架构师(一)第31节:Nginx简介、安装和基本运行
第一节:主要介绍Nginx和安装
- Java高级架构师(一)第28节:Index、商品详细页和购物车
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding= ...
- Java高级架构师(一)第26节:测试并调整登录的业务功能
主Index的处理Java: package com.sishuok.architecture1; import org.springframework.beans.factory.annotatio ...
- Java高级架构师(一)第25节:实现前端的业务登录等功能
package com.sishuok.architecture1; import javax.servlet.http.Cookie; import javax.servlet.http.HttpS ...
- Java高级架构师(一)第19节:X-gen生成相应的Visitor
package cn.javass.themes.smvcsm.visitors; import cn.javass.xgen.genconf.vo.ExtendConfModel; import c ...
随机推荐
- NetTime
NetTime NetTime is a Simple Network Time Protocol (SNTP) client for Windows 95/98/Me/NT/2000/XP/Vist ...
- React 开发常见报错解决方法
1. 使用 redux 的异步 action 时浏览器报错: Error: Actions must be plain objects. Use custom middleware for async ...
- Dozer数据对象转换神器
Dozer数据对象转换神器
- 【FJWC2017】交错和查询 [线段树]
交错和查询 Time Limit: 10 Sec Memory Limit: 256 MB Description 无限循环数字串S由长度为n的循环节s构成.设s为12345(n=5),则数字串S为 ...
- vue入门介绍
vue:解决前端大型应用的开发,将之前几十个.几百个.更多的HTML页面集成1个html页面(单页面应用)jquery:前端方法库bootstrap:UI组件库 angular/react这两个框架都 ...
- 也说JS脚本加载控制
问题背景 前端采用的 iframe + html 做后台管理系统.现在js.jquery插件非常多,每次页面都是引用就类似这样: <script src="../Scripts/jqu ...
- jQuery获取表格隐藏域与ajax请求数据结合显示详情
0.表格样式
- Make recursive
folder structure: Makefile t1/Makefile t1/t1.c t2/Makefile t2/t2.c Makefile SUBDIRS = t1 t2 all: for ...
- Google的C++开源代码项目
Google的C++开源代码项目 http://www.open-open.com/lib/view/open1413873531356.html v8 - V8 JavaScript Engin ...
- 慎用Java递归调用
总结:慎用Java递归调用,测试时可以尝试该方法,否则尽量不要使用递归!递归过多调用时,最好改为for或者whlie来代替. 在java语言中,使用递归调用时,如果过多的调用容易造成java.lang ...