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. SQL 1:常用SQL语句

    导读:最近写代码,几乎是天天泡在SQL语句里,各种代码各种写.但一直缺少总结,要不就是觉得简单,要不就是觉得大家都知道.想来,我还是没能明白总结的价值在哪里.现在也就写写最近都常写的一些语句. 一,i ...

  2. Loadrunner:安装LR11.0破解步骤及License

    破解步骤: 1.关闭LR相关程序 2.运行LicenseDelete程序,清除LR原来的License 3.将lm70.dll和mlr5lprg.dll这两个文件复制并粘贴到LR安装目录下的bin文件 ...

  3. Track files and folders manipulation in Windows

    The scenario is about Business Secret and our client do worry about data leakage. They want to know ...

  4. eclipse自动补全

    最简单的修改方式是:Windows——>Preferences——>Java-->Editor-->Content Asist,在Auto activation trigger ...

  5. u-boot board_uart_init流程

    /** ****************************************************************************** * @author    Maox ...

  6. Js/Ajax中发送HttpPost请求调用WebService

    1) WebService中的方法 [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(Confo ...

  7. Windows Server 2008 R2 实现多用户连接远程桌面

    前提 1. 确认自己的计算机开启了远程连接 2. 在远程桌面会话主机配置中将"限制每个用户只能进行一个会话"的勾去掉. 实现方法 1. 需要在角色里面安装远程桌面服务: 2. 在用 ...

  8. Kettle 合并记录报错!

    在Kettle的合并记录过程的时候,在“为了转换解除补丁开始 ”这一步的时候报错.具体错误如图所示: Kettle的转换如图所示: 问题原因:可能是你的数据库链接驱动和Kettle的版本不兼容. 解决 ...

  9. jQuery中ajax调用当前页面方法

    $.ajax({ type: 'POST', url: 'AddressManager.aspx/GetProvince',//AddressManager.aspx当前页面 data: '{cach ...

  10. luigi学习-luigi的配置文件

    一.luigi配置文件的加载顺序 /etc/luigi/client.cfg luigi.cfg LUIGI_CONFIG_PATH环境变量 二.配置文件分节 配置文件被分为了多个section,每一 ...