1. beans.xml的配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<context:property-placeholder location="classpath:conf/jdbc.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${con.driverClassName}"></property>
<property name="url" value="${con.url}"></property>
<property name="username" value="${con.username}"></property>
<property name="password" value="${con.password}"></property>
<property name="maxActive" value="${con.maxActive}"></property>
<property name="initialSize" value="${con.initialSize}"></property>
<property name="maxIdle" value="${con.maxIdle}"></property>
<property name="minIdle" value="${con.minIdle}"></property>
</bean>
<!-- mybatis文件配置,扫描所有mapper文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
p:dataSource-ref="dataSource" p:configLocation="classpath:conf/mybatis-config.xml"
p:mapperLocations="classpath:mapper/*.xml" /><!-- configLocation为mybatis属性
mapperLocations为所有mapper -->
<!-- spring与mybatis整合配置,扫描所有dao -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:basePackage="com.green.phonemanage.dao" p:sqlSessionFactoryBeanName="sqlSessionFactory" />
<!-- 对数据源进行事务管理 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="dataSource" />
<tx:annotation-driven transaction-manager="transactionManager" />
<context:annotation-config />
<!-- 设置不过滤内容,比如:css,jquery,img 等资源文件 -->
<mvc:default-servlet-handler/>
<bean class="com.green.phonemanage.service.impl.ClientServiceImpl"
id="clientService"></bean>
<bean class="com.green.phonemanage.service.impl.PhoneServiceImpl"
id="phoneService"></bean>
<bean class="com.green.phonemanage.service.impl.UserServiceImpl"
id="userService"></bean>
<context:component-scan base-package="com.green.phonemanage.controller"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<!-- Freemarker配置 -->
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/fl/" />
<property name="freemarkerSettings">
<props>
<prop key="template_update_delay"></prop>
<prop key="default_encoding">UTF-</prop>
<prop key="number_format">.##########</prop>
<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
<prop key="classic_compatible">true</prop>
<prop key="template_exception_handler">ignore</prop>
</props>
</property>
</bean>
<!--视图解释器 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="suffix">
<value>.html</value>
</property>
<property name="contentType" value="text/html;charset=UTF-8"></property>
<property name="requestContextAttribute" value="base"></property>
</bean>
<!-- 通过注解对数据处理的适配 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-</value>
<value>text/plain;charset=UTF-</value>
</list>
</property>
</bean>
<bean
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
</list>
</property>
</bean>

2. LoginController

package com.green.phonemanage.controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.green.phonemanage.model.MenuItem;
@Controller
public class LoginController {
@RequestMapping(value="/web/toIndex",method=RequestMethod.GET)
public ModelAndView loginToIndex(String loginName,int role,int userId){
ModelAndView andView=new ModelAndView("index");
andView.addObject("loginName",loginName);
andView.addObject("role", role);
andView.addObject("userId", userId);
return andView;
} }

3. UserController

package com.green.phonemanage.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
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.RestController;
import com.green.phonemanage.dao.UserDao;
import com.green.phonemanage.model.Msg;
import com.green.phonemanage.model.SearchForm;
import com.green.phonemanage.model.User;
import com.green.phonemanage.model.UserMsg;
import com.green.phonemanage.service.IUserService;
@RestController
public class UserController {
@Autowired
private IUserService userService;
public void setUserService(IUserService userService) {
this.userService = userService;
}
@Autowired
private UserDao userDao;
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
/*
* �û���¼
*
* @param:��¼��
*
* @param:����
*
* @param:��ɫ��1.�ͻ���2������Ա
*
* @return:��¼��Ϣ
*/
@RequestMapping(value = "/user/login", method = RequestMethod.POST)
public UserMsg login(@RequestParam String loginName, @RequestParam String passwd,
@RequestParam int role) {
User user = new User();
user.setLoginName(loginName);
user.setPasswd(passwd);
user.setRole(role);
return userService.login(user);
}
/*
* �û�ע��
*
* @param:�û���Ϣ
*
* @return:�û�ע����Ϣ
*/
@RequestMapping(value = "user/register", method = RequestMethod.POST,produces="application/json",consumes="application/json")
public UserMsg register(@RequestBody User user) {
user.setStatus(1);
return userService.register(user);
}
/*
* 查询登录名是否存在
*
* @param:登录名
*
* @return:状态
*/
@RequestMapping(value = "user/ne", method = RequestMethod.GET)
public UserMsg nameExist(@RequestParam("loginName") String loginName) {
UserMsg um = new UserMsg();
um.setMsg("登录名不存在");
um.setStatus(1);
Integer id = userDao.findByLoginName(loginName);
if (id != null) {
um.setStatus(0);
um.setMsg("登录名已经存在");
}
return um;
}
/*
* ͨ��id��ȡ�û���Ϣ
*
* @param:�û�id
*
* @return:�û���Ϣ
*/
@RequestMapping(value = "user/find", method = RequestMethod.GET)
public User findUser(@RequestParam("id") int id) {
return userDao.findById(id);
}
/*
* �û���Ϣ��ҳ��ѯ
*
* @param:��ҳ��Ϣ
*
* @return:�û���Ϣ�б�
*/
@RequestMapping(value = "user/finds", method = RequestMethod.POST)
public Map<String, Object> finds(SearchForm searchForm) {
searchForm.setPageIndex(searchForm.getPageIndex() * searchForm.getPageSize());
List<User> users = userDao.finds(searchForm);
Map<String, Object> datas = new HashMap<String, Object>();
datas.put("data", users);
datas.put("total", userDao.totals()==null?0:userDao.totals());
return datas;
}
/*
* ɾ��ָ�����û�
*
* @param:�û�id
*
* @return:��Ϣ
*/
@RequestMapping(value = "user/rm", method = RequestMethod.GET)
public Msg remove(@RequestParam("id") int id) {
Msg rmMsg = new Msg();
rmMsg.setId(id);
rmMsg.setMsg("ɾ���ɹ�");
rmMsg.setState(1);
try {
userDao.rmove(id);
} catch (Exception e) {
rmMsg.setState(0);
rmMsg.setMsg("ɾ��ʧ��");
}
return rmMsg;
}
/*
* �޸��û���Ϣ
*
* @param:�û�id
*
* @return:�û�״̬
*/
@RequestMapping(value = "user/update", method = RequestMethod.POST)
public Msg update(User user) {
Msg rmMsg = new Msg();
rmMsg.setId(user.getId());
rmMsg.setMsg("�޸ijɹ�");
rmMsg.setState(1);
try {
userDao.update(user);
} catch (Exception e) {
rmMsg.setState(0);
rmMsg.setMsg("�޸�ʧ��");
}
return rmMsg;
}
/*
* �û�����
*
* @param:�û�id
*
* @return:���ز���״̬
*/
@RequestMapping(value = "user/freeze", method = RequestMethod.GET)
public Msg freeze(@RequestParam("id") int id) {
Msg msg = new Msg();
msg.setId(id);
msg.setState(1);
msg.setMsg("成功");
try {
userDao.freeze(id);
} catch (Exception e) {
msg.setState(0);
msg.setMsg("失败");
}
return msg;
}
/*
* �û��ⶳ
*
* @param:�û�id
*
* @return:���ز���״̬
*/
@RequestMapping(value = "user/unfreeze", method = RequestMethod.GET)
public Msg unfreeze(@RequestParam("id") int id) {
Msg msg = new Msg();
msg.setId(id);
msg.setState(1);
msg.setMsg("成功");
try {
userDao.unfreeze(id);
} catch (Exception e) {
msg.setState(0);
msg.setMsg("失败");
}
return msg;
}
}

4. ClientController

package com.green.phonemanage.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
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.RestController;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonAnyFormatVisitor;
import com.fasterxml.jackson.databind.util.JSONPObject;
import com.green.phonemanage.dao.CellPhoneDao;
import com.green.phonemanage.dao.ClientDao;
import com.green.phonemanage.model.Client;
import com.green.phonemanage.model.Msg;
import com.green.phonemanage.model.SearchForm;
import com.green.phonemanage.service.IClientService;
;
@RestController
public class ClientController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private IClientService clientService;
public void setClientService(IClientService clientService) {
this.clientService = clientService;
}
@Autowired
private CellPhoneDao cellPhoneDao;
public void setCellPhoneDao(CellPhoneDao cellPhoneDao) {
this.cellPhoneDao = cellPhoneDao;
}
@Autowired
private ClientDao clientDao;
public void setClientDao(ClientDao clientDao) {
this.clientDao = clientDao;
}
@RequestMapping(value = "/tst", method = RequestMethod.GET)
public void tst(@RequestParam("id") int id) {
System.out.println("This is a test.");
}
/*
* 通鏌ユ壘瀹㈡埛
*
* @param:瀹㈡埛id
*
* @return:瀹㈡埛淇℃伅
*/
@RequestMapping(value = "/client/find", method = RequestMethod.GET, produces = "application/json", consumes = "application/json")
public Client findUser(@RequestParam("id") int id) {
return clientDao.findById(id);
}
/*
* 鍒嗛〉鑾峰彇瀹㈡埛淇℃伅
*
* @param:鍒嗛〉淇℃伅
*
* @return:鍒嗛〉鎵�鏈夊鎴蜂俊鎭�
*/
@RequestMapping(value = "client/finds", method = RequestMethod.POST)
public Map<String, Object> finds(SearchForm searchForm) {
searchForm.setPageIndex(searchForm.getPageIndex()
* searchForm.getPageSize());
List<Client> r = clientDao.finds(searchForm);
Map<String, Object> datas = new HashMap<String, Object>();
datas.put("data", r);
datas.put("total", clientDao.totals()==null?0:clientDao.totals());
return datas;
}
/*
* 绉婚櫎瀹㈡埛
*
* @param:瀹㈡埛id
*
* @return:鐘舵��
*/
@RequestMapping(value = "client/rm", method = RequestMethod.GET)
public Msg remove(@RequestParam("id") int id) {
Msg rmMsg = new Msg();
rmMsg.setId(id);
rmMsg.setMsg("刪除成功");
rmMsg.setState(1);
try {
Integer phoneId=null;
phoneId=cellPhoneDao.findByClient(id);
if(null==phoneId){
clientDao.rmove(id);
}else{
rmMsg.setState(0);
rmMsg.setMsg("手机被使用的用户,无法删除。");
}
} catch (Exception e) {
rmMsg.setState(0);
rmMsg.setMsg("手机被使用的用户,无法删除。");
}
return rmMsg;
}
/*
* 淇敼瀹㈡埛淇℃伅
*
* @param:瀹㈡埛淇℃伅
*
* @return:鐘舵�佔刺�
*
* @RequestMapping(value = "client/update", method = RequestMethod.POST)
* public Msg update(@ModelAttribute("client") Client client) {
*
* Msg rmMsg = new Msg(); rmMsg.setId(client.getId());
* rmMsg.setMsg("绉婚櫎鎴愬姛"); rmMsg.setState(1); try {
* clientDao.update(client); } catch (Exception e) { rmMsg.setState(0);
* rmMsg.setMsg("绉婚櫎澶辫触"); } return rmMsg; }
*/
/*
* 娣诲姞瀹㈡埛淇℃伅
*
* @param:瀹㈡埛淇℃伅
*
* @return:鐘舵�佔刺�
*/
@RequestMapping(value = "client/add", method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
public Msg add(@RequestBody Client client) {
logger.debug(client.toString());
Msg rmMsg = new Msg();
rmMsg.setId(client.getId());
rmMsg.setMsg("修改成功");
rmMsg.setState(1);
try {
clientService.add(client);
} catch (Exception e) {
rmMsg.setState(0);
rmMsg.setMsg("客戶已經存在");
}
return rmMsg;
}
}

5. CellPhoneController

package com.green.phonemanage.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
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.RestController;
import com.green.phonemanage.dao.CellPhoneDao;
import com.green.phonemanage.model.CellPhone;
import com.green.phonemanage.model.Msg;
import com.green.phonemanage.model.SearchForm;
import com.green.phonemanage.service.IPhoneService;
@RestController
public class CellPhoneController {
@Autowired
private IPhoneService phoneService;
public void setPhoneService(IPhoneService phoneService) {
this.phoneService = phoneService;
}
@Autowired
private CellPhoneDao cellPhoneDao;
public void setCellPhoneDao(CellPhoneDao cellPhoneDao) {
this.cellPhoneDao = cellPhoneDao;
}
/*
* ͨ查找手机
*
* @param:手机id
*
* @return:手机信息
*/
@RequestMapping(value = "cellphone/find", method = RequestMethod.GET)
public CellPhone findUser(@RequestParam("id") int id) {
return cellPhoneDao.findById(id);
}
/*
* 分页获取手机信息
*
* @param:分页信息
*
* @return:分页所有手机信息
*/
@RequestMapping(value = "cellphone/finds", method = RequestMethod.POST)
public Map<String, Object> finds(SearchForm searchForm) {
searchForm.setPageIndex(searchForm.getPageIndex() * searchForm.getPageSize());
List<CellPhone>r= cellPhoneDao.finds(searchForm);
Map<String, Object> datas = new HashMap<String, Object>();
datas.put("data", r);
datas.put("total", cellPhoneDao.totals()==null?0:cellPhoneDao.totals());
return datas;
}
/*
* 移除手机
*
* @param:手机id
*
* @return:状态
*/
@RequestMapping(value = "cellphone/rm", method = RequestMethod.GET)
public Msg remove(@RequestParam("id") int id) {
Msg rmMsg = new Msg();
rmMsg.setId(id);
rmMsg.setMsg("删除成功");
rmMsg.setState(1);
try {
cellPhoneDao.rmove(id);
} catch (Exception e) {
rmMsg.setState(0);
rmMsg.setMsg("删除失败");
}
return rmMsg;
}
/*
* 修改手機信息
*
* @param:手機信息
*
* @return:状态״̬
*/
@RequestMapping(value = "cellphone/update", method = RequestMethod.POST,consumes="application/json")
public Msg update(@RequestBody CellPhone cellphone) {
Msg rmMsg = new Msg();
rmMsg.setId(cellphone.getId());
rmMsg.setMsg("移除成功");
rmMsg.setState(1);
try {
phoneService.add(cellphone);
} catch (Exception e) {
rmMsg.setState(0);
rmMsg.setMsg("移除失败");
}
return rmMsg;
}
/*
* 添加手机信息
*
* @param:手机信息
*
* @return:状态״̬
*/
@RequestMapping(value = "cellphone/add", method = RequestMethod.POST,consumes="application/json")
public Msg add(@RequestBody CellPhone cellphone) {
cellphone.setStatus(1);
Msg rmMsg = new Msg();
rmMsg.setId(cellphone.getId());
rmMsg.setMsg("添加成功");
rmMsg.setState(1);
try {
phoneService.add(cellphone);
} catch (Exception e) {
rmMsg.setState(0);
rmMsg.setMsg("添加失败");
}
return rmMsg;
}
}

6. MenuController

package com.green.phonemanage.controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.green.phonemanage.model.MenuItem;
@RestController
public class MenuController {
@RequestMapping(value = "/menu", method = RequestMethod.GET,produces="application/json")
public List<MenuItem> menu(int role){
List<MenuItem>items=new ArrayList<MenuItem>();
if(role==1){
MenuItem itemTop=new MenuItem();
itemTop.setId("top");
itemTop.setIconCls("icon-add");
itemTop.setText("系统管理");
items.add(itemTop);
MenuItem itemPhone=new MenuItem();
itemPhone.setId("phone");
itemPhone.setText("手机管理");
itemPhone.setIconCls("Phone");
itemPhone.setUid("top");
itemPhone.setIconPosition("top");
itemPhone.setUrl("web/cellphone/index");
items.add(itemPhone);
MenuItem itemClient=new MenuItem();
itemClient.setId("client");
itemClient.setText("客户管理");
itemClient.setIconCls("Client");
itemClient.setUid("top");
itemClient.setIconPosition("top");
itemClient.setUrl("web/client/index");
items.add(itemClient);
MenuItem itemUser=new MenuItem();
itemUser.setId("user");
itemUser.setText("用户设置");
itemUser.setUid("top");
itemUser.setIconPosition("top");
itemUser.setIconCls("User");
itemUser.setUrl("web/user/edit");
items.add(itemUser);
}
if(role==2){
MenuItem itemTop=new MenuItem();
itemTop.setId("top");
itemTop.setIconCls("icon-add");
itemTop.setText("系统管理");
items.add(itemTop);
MenuItem itemPhone=new MenuItem();
itemPhone.setId("phone");
itemPhone.setText("手机管理");
itemPhone.setIconCls("Phone");
itemPhone.setUid("top");
itemPhone.setIconPosition("top");
itemPhone.setUrl("web/cellphone/index");
items.add(itemPhone);
MenuItem itemClient=new MenuItem();
itemClient.setId("client");
itemClient.setText("客户管理");
itemClient.setIconCls("Client");
itemClient.setUid("top");
itemClient.setIconPosition("top");
itemClient.setUrl("web/client/index");
items.add(itemClient);
MenuItem itemUser=new MenuItem();
itemUser.setId("user");
itemUser.setText("用户管理");
itemUser.setUid("top");
itemUser.setIconPosition("top");
itemUser.setIconCls("User");
itemUser.setUrl("web/user/index");
items.add(itemUser);
MenuItem itemPwd=new MenuItem();
itemPwd.setId("pwd");
itemPwd.setText("修改密码");
itemPwd.setUid("top");
itemPwd.setIconPosition("top");
itemPwd.setIconCls("Pwd");
itemPwd.setUrl("web/user/edit/pwd");
items.add(itemPwd);
}
MenuItem itemTop2=new MenuItem();
itemTop2.setId("top2");
itemTop2.setIconCls("icon-add");
itemTop2.setText("分析");
items.add(itemTop2);
MenuItem itemStatus=new MenuItem();
itemStatus.setId("status");
itemStatus.setText("状态");
itemStatus.setUid("top2");
itemStatus.setIconPosition("left");
itemStatus.setIconCls("status");
itemStatus.setUrl("web/bar/status");
items.add(itemStatus);
MenuItem itemBrand=new MenuItem();
itemBrand.setId("brand");
itemBrand.setText("品牌");
itemBrand.setUid("top2");
itemBrand.setIconPosition("left");
itemBrand.setIconCls("brand");
itemBrand.setUrl("web/bar/brand");
items.add(itemBrand);
MenuItem itemCity=new MenuItem();
itemCity.setId("city");
itemCity.setText("地址");
itemCity.setUid("top2");
itemCity.setIconPosition("left");
itemCity.setIconCls("city");
itemCity.setUrl("web/bar/address");
items.add(itemCity);
return items;
}

7. BarViewController

package com.green.phonemanage.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/web/bar/")
public class BarViewController {
@RequestMapping(value = "status", method = RequestMethod.GET)
public ModelAndView toStatus() {
ModelAndView andView = new ModelAndView("/bar/status"); return andView;
}
@RequestMapping(value = "address", method = RequestMethod.GET)
public ModelAndView toAddress() {
ModelAndView andView = new ModelAndView("/bar/address"); return andView;
}
@RequestMapping(value = "brand", method = RequestMethod.GET)
public ModelAndView toBrand() {
ModelAndView andView = new ModelAndView("/bar/brand"); return andView;
}
}

8. CellPhoneViewController

package com.green.phonemanage.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@RequestMapping("/web/cellphone/")
@Controller
public class CellPhoneViewController {
@RequestMapping(value = "index", method = RequestMethod.GET)
public ModelAndView index() {
ModelAndView andView = new ModelAndView("cellphone/index");
return andView;
}
@RequestMapping(value = "edit", method = RequestMethod.GET)
public ModelAndView edit() {
ModelAndView andView = new ModelAndView("cellphone/edit");
return andView;
}
@RequestMapping(value = "aedit", method = RequestMethod.GET)
public ModelAndView aedit() {
ModelAndView andView = new ModelAndView("cellphone/aedit");
return andView;
}
}

9. ClientViewController

package com.green.phonemanage.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/web/client")
public class ClientViewController {
@RequestMapping(value = "index", method = RequestMethod.GET)
public ModelAndView index() {
ModelAndView andView = new ModelAndView("client/index");
return andView;
}
@RequestMapping(value = "edit", method = RequestMethod.GET)
public ModelAndView edit() {
ModelAndView andView = new ModelAndView("client/edit");
return andView;
}
@RequestMapping(value = "eindex", method = RequestMethod.GET)
public ModelAndView aedit() {
ModelAndView andView = new ModelAndView("client/eindex");
return andView;
}
}

10. TotalController

package com.green.phonemanage.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.green.phonemanage.model.SearchTotal;
import com.green.phonemanage.service.IPhoneService;
@RestController
public class TotalController {
@Autowired
private IPhoneService phoneService;
public void setPhoneService(IPhoneService phoneService) {
this.phoneService = phoneService;
}
@RequestMapping(value = "/total/data", method = RequestMethod.GET)
public List<SearchTotal> datas(int type) {
return phoneService.findTotal(type);
}
}

11. UserViewController

package com.green.phonemanage.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/web/user/")
public class UserViewController {
@RequestMapping(value = "index", method = RequestMethod.GET)
public ModelAndView index() {
ModelAndView andView = new ModelAndView("/user/index"); return andView;
}
@RequestMapping(value = "edit", method = RequestMethod.GET)
public ModelAndView edit() {
ModelAndView andView = new ModelAndView("/user/edit");
return andView;
}
@RequestMapping(value = "edit/pwd", method = RequestMethod.GET)
public ModelAndView editPwd() {
ModelAndView andView = new ModelAndView("/user/pwdedit");
return andView;
}
}

以上是近期一个简单管理系统SpringMVC用法,其中前端用的是miniui框架。

SpringMVC综合使用手机管理系统Controller层开发的更多相关文章

  1. ssh_maven之controller层开发

    我们已经完成了前两层的开发,现在 只剩下我们的controller层了,对于这一层,我们需要创建一个动作类CustomerAction,另外就是我们的strutss.xml以及我们的applicati ...

  2. PowerMock+SpringMVC整合并测试Controller层方法

    PowerMock扩展自Mockito,实现了Mockito不支持的模拟形式的单元测试.PowerMock实现了对静态方法.构造函数.私有方法以及final方法的模拟支持,对静态初始化过程的移除等强大 ...

  3. Springmvc入门基础(五) ---controller层注解及返回类型解说

    0.@Controller注解 作用:通过@Controller注解,注明该类为controller类,即控制器类,需要被spring扫描,然后注入到IOC容器中,作为Spring的Bean来管理,这 ...

  4. SpringMVC在Controller层中注入request的坑

    记一次为了节省代码没有在方法体中声明HttpServletRequest,而用autowire直接注入所钻的坑 结论 给心急的人. 直接在Controller的成员变量上使用@Autowire声明Ht ...

  5. SpringMVC的controller层接收来自jsp页面通过<a href="/user/userUpdateInfo/>的中文乱码问题

    这种情况是,jsp页面的中文正常显示,数据的中文也是正常显示,但是在Controller层接收到的中文是乱码,如下图所示: 解决方法:在Controller层对前台传递的中文乱码进行处理,将它转换成u ...

  6. springmvc controller层接收List类型的参数

    Spring MVC在接收集合请求参数时,需要在Controller方法的集合参数里前添加@RequestBody,而@RequestBody默认接收的enctype (MIME编码)是applica ...

  7. springMVC中controller层方法中使用private和public问题

    楼主一直习惯使用public,偶尔手误也可能使用private,但是发觉也没啥区别,都能调用service层,注入bean. 后来做一个新项目时,发觉自己以前的写的部分功能报错,当时有点懵逼,,找了半 ...

  8. Winform开发框架之客户关系管理系统(CRM)的开发总结系列2-基于框架的开发过程

    在上篇随笔<Winform开发框架之客户关系管理系统(CRM)的开发总结系列1-界面功能展示>中介绍了我的整个CRM系统的概貌,本篇继续本系列的文章,介绍如何基于我的<winform ...

  9. SSH综合练习-仓库管理系统-第二天

    SSH综合练习-仓库管理系统-第二天 今天的主要内容: 货物入库 页面信息自动补全回显功能:(学习目标:练习Ajax交互) 根据货物简记码来自动查询回显已有货物(Ajax回显) 根据货物名来自动查询补 ...

随机推荐

  1. 自己的3dmax作品RX-105柯西高达

    背后视角带导弹仓. 侧面. 侧后视角. 前侧视角. 斜前上视角 使用关联实现骨骼功能,头.躯干.肩.上臂.前臂.手腕.手指.腰.髋关节.踝关节.脚掌皆由骨骼(是通过多边形关联实现骨骼功能,而不是使用3 ...

  2. Android开发-API指南-Bound 类型的服务

    Bound Services 英文原文:http://developer.android.com/guide/components/bound-services.html 采集(更新)日期:2014- ...

  3. Oracle数据库(1)

    Oracle基本数据类型:Oracle的基本呢数据类型按类型分为:字符串类型,数据类型,日期类型,LOB类型等.1.字符串类型:①char:定长字符串,最多存储2k字节,在不指定char长度的情况下, ...

  4. Oracle 查看表空间剩余与创建空间语法

    select a.tablespace_name,total,free,total-free used from ( select tablespace_name,sum(bytes)/1024/10 ...

  5. Java导出数据为EXCEL的两种方式JXL和POI

    JXL和POI导出数据方式的比较 POI支持excel2003和2007,而jxl只支持excel2003. 下面为测试代码: public class TestCondition { /** * 生 ...

  6. ASP.NET MVC 开源项目学习之ProDinner (一)

    首先在github上面将ProDinner项目通过 Git Bash 克隆到本地,接下来我们开始分析这个项目吧~ 系统采用.Net 4.5, Asp.net Mvc 5,VS2012,Sql serv ...

  7. UIBezierPath IOS贝塞尔曲线

    //记录  贝塞尔曲线使用 //根据一个矩形画曲线 + (UIBezierPath *)bezierPathWithRect:(CGRect)rect //根据矩形框的内切圆画曲线 + (UIBezi ...

  8. linux 文本处理

    tr,awk,sed 一:tr 1.大小写转换 cat file | tr [a-z] [A-Z] > new_file(大写 --> 小写) cat file | tr [A-Z] [a ...

  9. centOS 6.4下安装中文输入法

    1.用root登录 ,或su root 2.yum install "@Chinese Support" 3.exit 4.回到桌面,system->preferences- ...

  10. poj3122 pie

    方法:二分. 题目意思:要过生日了,我请大家吃pie,然后人数一共是f+1(我自己).每个人的pie不能是拼接的,而且每个人的面积是一样的,这样就用二分枚举. 范围是0-最大的那块pie. 然后用每一 ...