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 ...
随机推荐
- Error in deleting blocks.
2014-08-24 22:15:21,714 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Error processing datan ...
- Python之日志操作(logging)
import logging 1.自定义日志级别,日志格式,输出位置 logging.basicConfig( level=logging.DEBUG, format='%(asctime)s | ...
- php函数-shuffle
Shuffle()函数说明: -随机乱序现有数组并不保留键值: -shuffle()函数把数组中的元素按随机顺序重新排列,该函数为数组中的元素分配新的键名,已有键名将被删除. 语法说明: shuffl ...
- netty的Udp单播、组播、广播实例+Java的Udp单播、组播、广播实例
网络上缺乏netty的udp的单播.组播案例,经过一番学习总结之后终于把这两个案例调通,下面把这两个案例的代码放在这里分享一下. 首先推荐博文: http://colobu.com/2014/10/2 ...
- bzoj 1692: [Usaco2007 Dec]队列变换 ——二分+hash
Description FJ打算带他的N(1 <= N <= 30,000)头奶牛去参加一年一度的“全美农场主大奖赛”.在这场比赛中,每个参赛者都必须让他的奶牛排成一列,然后领她们从裁判席 ...
- 1552: [Cerc2007]robotic sort
这道题用splay写 先离散化数据保证按题目所述顺序来写 按原序作为键值建树 维护区间最小值去跑 每次将i的位置 和 n的位置x和y找出来后 将x旋转到root y旋转到x的有儿子 这时y的左子树就是 ...
- BZOJ 100题纪念
- Linux eject弹出光驱
Linux eject命令用于退出抽取式设备. 若设备已挂入,则eject会先将该设备卸除再退出. 语法 eject [-dfhnqrstv][-a <开关>][-c <光驱编号&g ...
- [Leetcode Week3]Course Schedule
Course Schedule题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/course-schedule/description/ Descript ...
- 解析gtest框架运行机制
前言 Google test是一款开源的白盒单元测试框架,据说目前在Google内部已在几千个项目中应用了基于该框架的白盒测试. 最近的工作是在搞一个基于gtest框架搭建的自动化白盒测试项目,该项目 ...