Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面。Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块。使用 Spring 可插入的 MVC 架构,可以选择是使用内置的 Spring Web 框架还可以是 Struts 这样的 Web 框架。

基本资料

Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块。 使用 Spring 可插入的 MVC 架构,可以选择是使用内置的 Spring Web 框架还是 Struts 这样的 Web 框架。通过策略接口,Spring 框架是高度可配置的,而且包含多种视图技术,例如 JavaServer Pages(JSP)技术、Velocity、Tiles、iText 和 POI。Spring MVC 框架并不知道使用的视图,所以不会强迫您只使用 JSP 技术。Spring MVC 分离了控制器、模型对象、分派器以及处理程序对象的角色,这种分离让它们更容易进行定制

优点介绍

Lifecycle for overriding binding, validation, etc.;易于同其它View框架(Titles等)无缝集成,采用IOC便于测试。

它是一个典型的教科书式的mvc构架,而不像struts等都是变种或者不是完全基于mvc系统的框架,对于初学者或者想了解mvc的人来说我觉得 spring是最好的,它的实现就是教科书!第二它和tapestry一样是一个纯正的servlet系统,这也是它和tapestry相比 struts所没有的优势。而且框架本身有代码,而且看起来也不费劲比较简单可以理解。

Spring Web MVC处理请求的流程

applicationContext.xm

<?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:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--<mvc:default-servlet-handler/>-->
<!-- <mvc:resources mapping="/image/" location="/image/**"></mvc:resources>-->
<!-- <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>-->
<!-- <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/h1.do">firstController</prop>
<prop key="/h2.do">firstController</prop>
</props>
</property>
</bean>-->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/*.do" value="firstController"></entry>
</map>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<bean id="firstController" class="cn.curry.controller.MyController"></bean>
</beans>

MyController

public class MyController implements Controller {
public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
ModelAndView mav = new ModelAndView();
mav.addObject("msg", "呵呵第一个SpringMVC");
mav.setViewName("index");
return mav;
}

web.xml

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app>
<display-name>Archetype Created Web Application</display-name> <servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> <servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</url-pattern>
</servlet-mapping>
<!--欢迎页-->
<welcome-file-list>
<welcome-file>/WEB-INF/jsps/index.jsp</welcome-file>
</welcome-file-list> </web-app>

实例二

applicationContext.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:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--<mvc:default-servlet-handler/>-->
<!--<mvc:resources mapping="/image/" location="/image/**"></mvc:resources>-->
<!--<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>-->
<!--<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/my.do">firstController</prop>
</props>
</property>
</bean>-->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/*.do" value="firstController"></entry>
</map>
</property>
</bean>
<bean id="nameResolver" class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/h1.do">doFirst</prop>
<prop key="/h2.do">doSecond</prop>
</props>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- <bean id="hi.do" class="cn.curry.controller.MyController">
<property name="supportedMethods" value="POST,GET"></property>
</bean>-->
<bean id="firstController" class="cn.curry.controller.MyMultiActionController">
<property name="methodNameResolver" ref="nameResolver"></property>
</bean>
</beans>
MyMultiActionController
package cn.curry.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; /**
* Created by Curry on 2017/4/10.
*/
public class MyMultiActionController extends MultiActionController {
public ModelAndView doFirst(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
ModelAndView mav = new ModelAndView();
mav.addObject("msg", "呵呵第一个SpringMVC");
mav.setViewName("index");
return mav;
}
public ModelAndView doSecond(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
ModelAndView mav = new ModelAndView();
mav.addObject("msg", "呵呵第二个SpringMVC");
mav.setViewName("index");
return mav;
}
}

实例三

application.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:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--<mvc:default-servlet-handler/>-->
<!--<mvc:resources mapping="/image/" location="/image/**"></mvc:resources>-->
<!--<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>-->
<!--<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/my.do">firstController</prop>
</props>
</property>
</bean>-->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/*.do" value="firstController"></entry>
</map>
</property>
</bean>
<bean id="nameResolver" class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/h1.do">doFirst</prop>
<prop key="/h2.do">doSecond</prop>
</props>
</property>
</bean>
<!--<bean id="nameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName" value="actionName"></property>
</bean>-->
<!--<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>-->
<!--<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/> <bean id="baidu" class="org.springframework.web.servlet.view.RedirectView">
<property name="url" value="http://www.baidu.com"></property>
</bean> <bean id="keke" class="org.springframework.web.servlet.view.JstlView">
<property name="url" value="/WEB-INF/jsps/index.jsp"></property>
</bean>-->
<bean class="org.springframework.web.servlet.view.XmlViewResolver">
<property name="location" value="classpath:myView.xml"></property>
</bean> <bean id="firstController" class="cn.curry.controller.MyMultiActionController">
<property name="methodNameResolver" ref="nameResolver"></property>
</bean>
</beans>

myView.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:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- <bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>--> <bean id="baidu" class="org.springframework.web.servlet.view.RedirectView">
<property name="url" value="http://www.22ddkk.cn"></property>
</bean> <bean id="keke" class="org.springframework.web.servlet.view.JstlView">
<property name="url" value="/WEB-INF/jsps/index.jsp"></property>
</bean>
</beans>

实例四

<?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:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <context:component-scan base-package="cn.curry"></context:component-scan>
<!--<mvc:default-servlet-handler/>-->
<!--<mvc:resources mapping="/image/" location="/image/**"></mvc:resources>-->
<!--<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>-->
<!--<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/my.do">firstController</prop>
</props>
</property>
</bean>-->
<!-- <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/*.do" value="firstController"></entry>
</map>
</property>
</bean>-->
<!-- <bean id="nameResolver" class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/h1.do">doFirst</prop>
<prop key="/h2.do">doSecond</prop>
</props>
</property>
</bean>-->
<!--<bean id="nameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName" value="actionName"></property>
</bean>-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!--<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/> <bean id="baidu" class="org.springframework.web.servlet.view.RedirectView">
<property name="url" value="http://www.baidu.com"></property>
</bean> <bean id="keke" class="org.springframework.web.servlet.view.JstlView">
<property name="url" value="/WEB-INF/jsps/index.jsp"></property>
</bean>-->
<!-- <bean class="org.springframework.web.servlet.view.XmlViewResolver">
<property name="location" value="classpath:myView.xml"></property>
</bean>--> <!-- <bean id="firstController" class="MyMultiActionController">
<property name="methodNameResolver" ref="nameResolver"></property>
</bean>-->
</beans>
package cn.curry.entity;

/**
* Created by Curry on 2017/4/11.
*/
public class Users {
private Integer uids;
private String uname;
private Adress adress; public Integer getUids() {
return uids;
} public void setUids(Integer uids) {
this.uids = uids;
} public String getUname() {
return uname;
} public void setUname(String uname) {
this.uname = uname;
} public Adress getAdress() {
return adress;
} public void setAdress(Adress adress) {
this.adress = adress;
}
}
package cn.curry.entity;

/**
* Created by Curry on 2017/4/11.
*/
public class Adress {
private String adressss; public String getAdressss() {
return adressss;
} public void setAdressss(String adressss) {
this.adressss = adressss;
}
}
package cn.curry.controller;

import cn.curry.entity.Users;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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; /**
* Created by Curry on 2017/4/6.
*/
@Controller
public class MyController {
@RequestMapping(value = "/first",method = RequestMethod.POST)
public String doFirst(Model model, @RequestParam(value="uname",required = false) String uname) {
model.addAttribute("msg","注解SpringMVC111");
System.out.println(uname);
model.addAttribute("uname",uname);
return "index";
}
@RequestMapping("/first2")
public String doSecond(Model model,Users users) {
model.addAttribute("msg","注解SpringMVC222");
System.out.println(users.getUname());
System.out.println(users.getAdress().getAdressss());
model.addAttribute("uname",users.getUname());
model.addAttribute("adressss",users.getAdress().getAdressss());
return "index";
}
@RequestMapping(value = "/{name}/{age}/first",method = RequestMethod.POST)
public String doThree(Model model,@PathVariable("rname") String uname ,@PathVariable String uage) {
model.addAttribute("msg","注解SpringMVC111");
System.out.println(uname);
model.addAttribute("uname",uname);
model.addAttribute("uage",uage);
return "index";
}
}
package cn.curry.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; /**
* Created by Curry on 2017/4/10.
*/
public class MyMultiActionController extends MultiActionController {
public ModelAndView doFirst(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
ModelAndView mav = new ModelAndView();
//mav.addObject("msg", "呵呵第一个SpringMVC");
mav.setViewName("baidu");
return mav;
}
public ModelAndView doSecond(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
ModelAndView mav = new ModelAndView();
mav.addObject("msg", "呵呵第二个SpringMVC");
mav.setViewName("keke");
System.out.println("hehehehe");
return mav;
}
}
package cn.curry.controller;

import cn.curry.entity.Users;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map; /**
* Created by Curry on 2017/4/12.
*/
@Controller
public class AjaxCpntroller {
@RequestMapping(value = "/first.do")
public void doFirst(HttpServletResponse response) throws Exception {
Map<String,Users> map=new HashMap<String, Users>(); Users u1=new Users();
u1.setUname("开心");
u1.setUids(001);
Users u2=new Users();
u2.setUname("快乐");
u2.setUids(002); map.put("01",u1);
map.put("02",u2); String jsonString = JSON.toJSONString(map);
System.out.println(jsonString);
response.setCharacterEncoding("utf-8");
response.getWriter().write(jsonString);
response.getWriter().close(); }
}
package cn.curry.controller;

import cn.curry.entity.Users;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map; /**
* Created by Curry on 2017/4/12.
*/
@Controller
public class AjaxCpntrollerA {
@RequestMapping(value = "/second.do",produces = "text/html;charset=utf-8")
@ResponseBody
public String doFirst(HttpServletResponse response) throws Exception {
Map<String,Users> map=new HashMap<String, Users>(); Users u1=new Users();
u1.setUname("开心");
u1.setUids(001);
Users u2=new Users();
u2.setUname("快乐");
u2.setUids(002); map.put("01",u1);
map.put("02",u2); String jsonString = JSON.toJSONString(map);
response.setCharacterEncoding("utf-8");
return jsonString;
}
}
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
<title>添加</title>
</head>
<body>
<h2>哈哈${msg}</h2>
<h3>${uname} ${adressss}</h3>
<form method="post" action="/first2">
用户名<input name="uname"/>
地址<input name="adress.adressss"/>
<input type="submit" value="提交"/>
</form>
<img src="data:image/asp.jpg"/>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
<title>ajax</title>
<script type="text/javascript" src="js/jquery-3.1.1.js"></script>
<script type="text/javascript">
$(function(){
$('#btn').click(function () {
$.ajax({
url:"first.do",
type:"post",
success:function(data){
data=eval("("+data+")"); $.each(data,function (i,dom) {
alert(dom.uname+"和"+dom.uids);
var li="<li>"+dom.uname+"</li>";
var li2="<li>"+dom.uids+"</li>";
$("#aa").append(li);
$("#aa").append(li2);
});
}
});
});
});
</script>
</head> <body>
<input type="button" id="btn" value="提交"/>
<ul id="aa"> </ul>
</body>
</html>

springmvc学习经验的更多相关文章

  1. 从技术小白到收获BAT研发offer,分享我的学习经验和感悟(赠送相关学习资料)

    去年秋季参加了校园招聘,有幸拿到了BAT.头条.网易.滴滴.亚马逊.华为等offer,经过研究生两年的学习积累,终于达成了自己的目标,期间也经历了很多,谨以此文,聊表感叹,也会分享很多我的Java学习 ...

  2. [转]C语言指针学习经验总结浅谈

    指针是C语言的难点和重点,但指针也是C语言的灵魂 . 这篇C语言指针学习经验总结主要是我入职以来学习C指针过程中的点滴记录.文档里面就不重复书上说得很清楚的概念性东西,只把一些说得不清楚或理解起来比较 ...

  3. SpringMVC学习系列-后记 解决GET请求时中文乱码的问题

    SpringMVC学习系列-后记 解决GET请求时中文乱码的问题 之前项目中的web.xml中的编码设置: <filter> <filter-name>CharacterEnc ...

  4. 史上最全的SpringMVC学习笔记

    SpringMVC学习笔记---- 一.SpringMVC基础入门,创建一个HelloWorld程序 1.首先,导入SpringMVC需要的jar包. 2.添加Web.xml配置文件中关于Spring ...

  5. SpringMVC学习系列-后记 开启项目的OpenSessionInView

    在系列的 SpringMVC学习系列(12) 完结篇 的示例项目中,由于当时考虑到OpenSessionInView会对性能有一定的影响,所以就没有配置项目的OpenSessionInView.在ma ...

  6. SpringMVC学习系列-后记 结合SpringMVC和Hibernate-validator,根据后台验证规则自动生成前台的js验证代码

    在SpringMVC学习系列(6) 之 数据验证中我们已经学习了如何结合Hibernate-validator进行后台的数据合法性验证,但是通常来说后台验证只是第二道保险,为了更好的用户体验会现在前端 ...

  7. SpringMvc学习心得(五)控制器产生与构建

    SpringMvc学习心得(五)控制器产生与构建 标签: springspring mvc框架 2016-03-22 15:29 140人阅读 评论(0) 收藏 举报  分类: Spring(4)  ...

  8. springmvc学习笔记--REST API的异常处理

    前言: 最近使用springmvc写了不少rest api, 觉得真是一个好框架. 之前描述的几篇关于rest api的文章, 其实还是不够完善. 比如当遇到参数缺失, 类型不匹配的情况时, 直接抛出 ...

  9. springmvc学习笔记---面向移动端支持REST API

    前言: springmvc对注解的支持非常灵活和飘逸, 也得web编程少了以往很大一坨配置项. 另一方面移动互联网的到来, 使得REST API变得流行, 甚至成为主流. 因此我们来关注下spring ...

随机推荐

  1. web攻击之零:WEB攻击及防御技术汇总

    一.XSS攻击 [介绍] xss攻击是跨站脚本攻击,例如在表单中提交含有可执行的javascript的内容文本,如果服务器端没有过滤或转义这些脚本,而这些脚本由通过内容的形式发布到了页面上,这个时候如 ...

  2. poco时间操作

    Poco::DateTime Poco::Timespan Poco::Timestamp 时间操作 Poco::DateTime dt; //c++ 20才有 Calendar dt = dt + ...

  3. source和sh执行脚本时的差异

    在CentOS7下,有如下脚:sh02.sh. 1 用sh或者bash执行 先执行echo $firstname $lastname 再执行 sh sh02.sh 最后执行 echo $firstna ...

  4. c++常用函数STL

    完c++快一年了,感觉很有遗憾,因为一直没有感觉到c++的强大之处,当时最大的感觉就是这个东西的输入输出比C语言要简单好写. 后来我发现了qt,opencv,opengl,原来,c++好玩的狠. 在这 ...

  5. 转载:SharePoint 2010 自定义 字段 类型--------省市区联动

    最近有几个朋友问到了有关自定义字段类型的问题,为了让更多的人了解自定义字段类型的方法,特写一篇博客与大家分享,首先看一下解决方案目录 创建自定义类型分以下几个步骤: 第一步:添加SharePoint映 ...

  6. 2014 SCAU_ACM 暑期集训

    暑期集训,希望能在这段时间获得对得起自己的提升吧 时间:7.11~8.30 集训各专题内容: 1.贪心,递推,基础DP(背包,区间DP,状态压缩DP(去年出了不少于2道铜牌题,看着办)) 2.搜索(B ...

  7. POJ 2976 Dropping tests (二分+贪心)

    题意:给定 n 个分数,然后让你去年 m 个分数,使得把剩下的所有的分子和分母都相加的分数最大. 析:这个题并不是分子越大最后结果就越大,也不是整个分数越大,最后结果就越大的,我们可以反过来理解,要去 ...

  8. 51Nod - 1154 回文串划分(最少回文串dp)

    回文串划分 有一个字符串S,求S最少可以被划分为多少个回文串. 例如:abbaabaa,有多种划分方式.   a|bb|aabaa - 3 个回文串 a|bb|a|aba|a - 5 个回文串 a|b ...

  9. [Xcode 实际操作]六、媒体与动画-(3)使用CoreImage框架设置图片的单色效果

    目录:[Swift]Xcode实际操作 本文将演示如何使用图片框架,将图片转换成单色样式. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit ...

  10. LCS最大公共子序列【转载】

    在两个字符串中,有些字符会一样,可以形成的子序列也有可能相等,因此,长度最长的相等子序列便是两者间的最长公共字序列,其长度可以使用动态规划来求. 以s1={1,3,4,5,6,7,7,8},s2={3 ...