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层开发的更多相关文章

  1. Java高级架构师(一)第01节:整体课程概览

    本课程专注于构建:高可扩展性.高性能.大数据量.高并发.分布式的系统架构. 从零开始.全面系统.成体系的软件架构课程,循序渐进的讲述构建上述系统架构所需要的各种技术知识和技能. 适应人群: 1:有一定 ...

  2. 好好讲一讲,到底什么是Java高级架构师!

    一. 什么是架构师 曾经有这么个段子: 甲:我已经应聘到一家中型软件公司了,今天上班的时候,全公司的人都来欢迎我. 乙:羡慕ing,都什么人来了? 甲:CEO.COO.CTO.All of 程序员,还 ...

  3. JAVA高级架构师基础功:Spring中AOP的两种代理方式:动态代理和CGLIB详解

    在spring框架中使用了两种代理方式: 1.JDK自带的动态代理. 2.Spring框架自己提供的CGLIB的方式. 这两种也是Spring框架核心AOP的基础. 在详细讲解上述提到的动态代理和CG ...

  4. Java高级架构师(一)第42节:应用上Nginx过后的体系结构

    以后的架构思考方向: 体系结构的演变

  5. Java高级架构师(一)第31节:Nginx简介、安装和基本运行

    第一节:主要介绍Nginx和安装

  6. Java高级架构师(一)第28节:Index、商品详细页和购物车

    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding= ...

  7. Java高级架构师(一)第26节:测试并调整登录的业务功能

    主Index的处理Java: package com.sishuok.architecture1; import org.springframework.beans.factory.annotatio ...

  8. Java高级架构师(一)第25节:实现前端的业务登录等功能

    package com.sishuok.architecture1; import javax.servlet.http.Cookie; import javax.servlet.http.HttpS ...

  9. Java高级架构师(一)第19节:X-gen生成相应的Visitor

    package cn.javass.themes.smvcsm.visitors; import cn.javass.xgen.genconf.vo.ExtendConfModel; import c ...

随机推荐

  1. C ------ 标准函数介绍

    sprintf() 函数原型:int sprintf( char *buffer, const char *format [, argument] ... ); 功能介绍: 1.把一个字符串赋值(拷贝 ...

  2. java实现极简的LRU算法

    import java.util.LinkedHashMap;import java.util.Map; /** * LRU (Least Recently Used)  */public class ...

  3. linux 端口号、进程id、杀进程、查询tcp的连接(各种状态的)

    sudo netstat -antupkill -s 9 50713netstat -n | grep 61616netstat -n | awk '/^tcp/ {++S[$NF]} END {fo ...

  4. html初探

    HTML HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,他是一种制作万维网页面标准语言(标记).相当于定义统一的一套规则,大家都来遵守他,这样就可以让浏 ...

  5. RPC-Thrift(四)

    Client Thrift客户端有两种:同步客户端和异步客户端. 同步客户端 同步客户端比较简单,以RPC-Thrift(一)中的的例子为基础进行研究源码,先看一下类图. TServiceClient ...

  6. [BZOJ1984]月下“毛景树”解题报告|树链剖分

    Description 毛毛虫经过及时的变形,最终逃过的一劫,离开了菜妈的菜园. 毛毛虫经过千山万水,历尽千辛万苦,最后来到了小小的绍兴一中的校园里.爬啊爬~爬啊爬~~毛毛虫爬到了一颗小小的“毛景树” ...

  7. #学习方法2打印为空,说明#延迟加载#解决方案:将nameField等设置改在viewDidLoad中设置

    #学习方法#error调试#NSLog调试之无法进行数据传输,Edit无法现实之前编辑 的内容             https://www.evernote.com/shard/s227/sh/c ...

  8. appium===setup/setupclass的区别,以及@classmathod的使用方法

    一.装饰器 1.用setUp与setUpClass区别 setup():每个测试case运行前运行 teardown():每个测试case运行完后执行 setUpClass():必须使用@classm ...

  9. pressmuSpiderr

    #!/usr/bin/env python # encoding: utf-8 import requests from random import choice from lxml import h ...

  10. logging模块的使用

    # -*- coding: utf-8 -*- import os import time import logging import sys log_dir1=os.path.join(os.pat ...