标签:
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">0</prop> <prop key="default_encoding">UTF-8</prop> <prop key="number_format">0.##########</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-8</value> <value>text/plain;charset=UTF-8</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("?????"); 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层开发
标签:
原文地址:http://www.cnblogs.com/maybo/p/5189575.html