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 ...
随机推荐
- javascript提示抖动实现方法
css代码: <style type="text/css"> #div1{ width:200px; height:200px; background-color:or ...
- oracle有关游标的知识
一:前言 今天我自己第二次写游标,我擦,觉得自己在数据库方面需要很大的提高啊.今天遇到三个问题,第一个是oracle数据库中的数据拆分的问题,这个我用regexp_substr来进行解决,第二个问题就 ...
- Drupal7所见即所得模块CKEditor
初学Drupal(7.26),刚好遇到一个需要用到CKEditor模块的项目,于是就摸索着把它给装上了. 图片上传出问题 回到Drupal7的管理页面后刚好发现了对于CKEditor的“状态报告”(错 ...
- 标签 JLable 类
标签JLable上可以添加图像,当鼠标停留在标签上时,可以显示一段提示文字. package first; import javax.swing.*; import java.awt.*; impor ...
- asp单页面301跳转
<% Response.Status="301 Moved Permanently"Response.AddHeader "Location", &quo ...
- 【Python实例二】BeautifulSoup爬虫简单实践
前言 前面安装了BeautifulSoup库,现在就来实现一下吧. 目录 一.Urllib库的使用 二.BeautifulSoup的使用 三. 一个示例 ----------------------- ...
- How to learn wxPython
目录 How to learn wxPython Learn Python Choose a good editor Install wxPython Read the wxPython tutori ...
- Mybatis三剑客
1.Mybatis-generator 自动化生成数据库交互代码->dao+pojo+xml 2.Mybatis-plugin dao文件和xml自动跳转,验证正确性,在xml中只能提示等功能 ...
- 【SQL】约束与触发器1
一.外键 1.1特点 表A的外键,一定是其他某个表B的主键或有UNIQUE声明的属性. A的外键的值,一定是对应表B中相应的属性值.(空值除外) 1.2声明方法 方法1:属性名 类型 REFERENC ...
- mysql的mysqladmin的用法
mysqladmin 适合于linux和windows系统 linux下:mysqladmin -u[username] -p[password] status windows下:先在安装目录找到my ...