老熟女激烈的高潮_日韩一级黄色录像_亚洲1区2区3区视频_精品少妇一区二区三区在线播放_国产欧美日产久久_午夜福利精品导航凹凸

重慶分公司,新征程啟航

為企業提供網站建設、域名注冊、服務器等服務

SpringMVC+FastJson+Swagger集成的完整實例教程

基礎部分

成都創新互聯服務項目包括新余網站建設、新余網站制作、新余網頁制作以及新余網絡營銷策劃等。多年來,我們專注于互聯網行業,利用自身積累的技術優勢、行業經驗、深度合作伙伴關系等,向廣大中小型企業、政府機構等提供互聯網行業的解決方案,新余網站推廣取得了明顯的社會效益與經濟效益。目前,我們服務的客戶以成都為中心已經輻射到新余省份的部分城市,未來相信會繼續擴大服務區域并繼續獲得客戶的支持與信任!

1. FastJson 簡介

Fastjson是一個Java庫,可用于將Java對象轉換為JSON表示。它也可以被用來將一個JSON字符串轉換成一個等效的Java對象。在轉換速度上應該是最快的,幾乎成為了項目的標配(在ajax請求和接口開發時一般都會用fastjson而不再使用jackson)。

GitHub: https://github.com/alibaba/fastjson (本地下載)

特性:

  • 服務器端和android客戶端提供最佳性能
  • 提供簡單toJSONString()和parseObject()方法的Java對象轉換為JSON,反之亦然
  • 允許存在的無法改變的對象轉換為從JSON
  • Java泛型的廣泛支持
  • 允許自定義表示對象
  • 支持任意復雜的對象(深繼承層次結構和廣泛使用泛型類型)

主要特點:

  • 快速FAST (比其它任何基于Java的解析器和生成器更快,包括jackson)
  • 強大(支持普通JDK類包括任意Java Bean Class、Collection、Map、Date或enum)
  • 零依賴(沒有依賴其它任何類庫除了JDK)
  • 支持注解

2. fastjson api

Fastjson API入口類是com.alibaba.fastjson.JSON,常用的序列化操作都可以在JSON類上的靜態方法直接完成。

// 把JSON文本parse為JSONObject或者JSONArray 
public static final Object parse(String text); 

// 把JSON文本parse成JSONObject 
public static final JSONObject parseObject(String text); 

// 把JSON文本parse為JavaBean 
public static final  T parseObject(String text, Class clazz); 

// 把JSON文本parse成JSONArray 
public static final JSONArray parseArray(String text); 

// 把JSON文本parse成JavaBean集合 
public static final  List parseArray(String text, Class clazz); 

// 將JavaBean序列化為JSON文本 
public static final String toJSONString(Object object); 

// 將JavaBean序列化為帶格式的JSON文本 
public static final String toJSONString(Object object, boolean prettyFormat); 

// 將JavaBean轉換為JSONObject或者JSONArray
public static final Object toJSON(Object javaObject); 

JSONArray:相當于List

JSONObject:相當于Map

SerializeConfig: 是對序列化過程中一些序列化過程的特殊配置, 如對一些字段進行格式處理(日期、枚舉等)

SerializeWriter:相當于StringBuffer

SerializerFeature屬性 :

  • QuoteFieldNames 輸出key時是否使用雙引號,默認為true
  • UseSingleQuotes 使用單引號而不是雙引號,默認為false
  • WriteMapNullValue 是否輸出值為null的字段,默認為false
  • WriteEnumUsingToString Enum輸出name()或者original,默認為false
  • UseISO8601DateFormat Date使用ISO8601格式輸出,默認為false
  • WriteNullListAsEmpty List字段如果為null,輸出為[],而非null
  • WriteNullStringAsEmpty 字符類型字段如果為null,輸出為”“,而非null
  • WriteNullNumberAsZero 數值字段如果為null,輸出為0,而非null
  • WriteNullBooleanAsFalse Boolean字段如果為null,輸出為false,而非null
  • SkipTransientField 如果是true,類中的Get方法對應的Field是transient,序列化時將會被忽略。默認為true
  • SortField 按字段名稱排序后輸出。默認為false
  • WriteTabAsSpecial 把\t做轉義輸出,默認為false 不推薦
  • PrettyFormat 結果是否格式化,默認為false
  • WriteClassName 序列化時寫入類型信息,默認為false。反序列化是需用到
  • DisableCircularReferenceDetect 消除對同一對象循環引用的問題,默認為false
  • WriteSlashAsSpecial 對斜杠'/'進行轉義
  • BrowserCompatible 將中文都會序列化為\uXXXX格式,字節數會多一些,但是能兼容IE 6,默認為false
  • WriteDateUseDateFormat 全局修改日期格式,默認為false。JSON.DEFFAULT_DATE_FORMAT = “yyyy-MM-dd”;JSON.toJSONString(obj, SerializerFeature.WriteDateUseDateFormat);
  • DisableCheckSpecialChar 一個對象的字符串屬性中如果有特殊字符如雙引號,將會在轉成json時帶有反斜杠轉移符。如果不需要轉義,可以使用這個屬性。默認為false
  • NotWriteRootClassName 含義
  • BeanToArray 將對象轉為array輸出
  • WriteNonStringKeyAsString
  • NotWriteDefaultValue
  • BrowserSecure
  • IgnoreNonFieldGetter
  • WriteEnumUsingName

實戰部分

Spring MVC+FastJson+Swagger集成的完整實例教程

1、pom.xml 中引入spring mvc、 fastjson 依賴


 4.0.0
 com.mengdee
 platform-springmvc-webapp
 war
 0.0.1-SNAPSHOT
 platform-springmvc-webapp Maven Webapp
 http://maven.apache.org

 
 UTF-8
 3.8.1
 2.5
 1.2
 4.2.3.RELEASE
 1.2.32

 

 
 
 junit
 junit
 3.8.1
 test
 

 
 javax.servlet
 jstl
 ${jstl.version}
 

 
 
 org.springframework
 spring-webmvc
 ${spring.version}
 
 
 org.springframework
 spring-core
 ${spring.version}
 
 
 org.springframework
 spring-context
 ${spring.version}
 
 
 org.springframework
 spring-context-support
 ${spring.version}
 
 
 org.springframework
 spring-jdbc
 ${spring.version}
 

 
 com.alibaba
 fastjson
 ${fastjson.version}
 

 

 
 
 
 aliyun
 aliyun
 http://maven.aliyun.com/nexus/content/groups/public
 
 

 
 platform-springmvc-webapp
 

2、 配置web.xml




 Archetype Created Web Application
 
 contextConfigLocation
 classpath:conf/spring/spring-*.xml
 

 
 Spring監聽器
 org.springframework.web.context.ContextLoaderListener
 

 
 spring-mvc
 org.springframework.web.servlet.DispatcherServlet
  
 contextConfigLocation 
 /WEB-INF/spring-servlet.xml 
 
 1
 
 
 spring-mvc
 /
 

 
 characterEncodingFilter
 org.springframework.web.filter.CharacterEncodingFilter
 
 encoding
 UTF-8
 
 
 forceEncoding
 true
 
 
 
 characterEncodingFilter
 /*
 


 
 /index.jsp
 

 
 404
 /index.jsp
 

3、 配置spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>


 

  
   
   
  
  
  

 
 
 
 
 
 
 
 text/html;charset=UTF-8
 application/json
 
 
 
 

 QuoteFieldNames 
 WriteMapNullValue 

 

 
 
 
 
 
 

4、Java

Education:學歷(枚舉類)

package com.mengdee.manage.entity;
import java.util.HashMap;
import java.util.Map;
/**
 * 學歷
 * @author Administrator
 *
 */
public enum Education {
 KINDERGARTEN("幼兒園", 1),
 ELEMENTARY("小學", 2),
 JUNIOR_MIDDLE("初級中學", 3),
 SENIOR_MIDDLE("高級中學", 4),
 UNIVERSITY("大學", 5),
 COLLEGE("學院", 6);
 private static final Map EDUCATION_MAP = new HashMap();
 static {
 for (Education education : Education.values()) {
 EDUCATION_MAP.put(education.getIndex(), education);
 }
 }

 private String text;
 private int index;

 private Education(String text, int index) {
 this.text = text;
 this.index = index;
 }


 public String getText() {
 return text;
 }

 public void setText(String text) {
 this.text = text;
 }

 public int getIndex() {
 return index;
 }

 public void setIndex(int index) {
 this.index = index;
 }


 public static Education getEnum(Integer index) {
 return EDUCATION_MAP.get(index);
 }
}

Person:

package com.mengdee.manage.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.annotation.JSONField;
public class Person {

 private Long id;
 private String name;

 private byte gender; // 性別 1:男 2:女
 private short age; // 年齡
 private long salary; // 薪水
 private double weight; // 體重
 private char level; // 評級

 private boolean adult; // 是否成年人
 private Date birthday; // 生日
 private Education education;// 學歷

 private String[] hobbies; // 愛好
 private List dogs; // 寵物狗
 private Map address; // 住址

 // 使用注解控制是否要序列化
 @JSONField(serialize = false)
 private List obj = new ArrayList<>();

 public Person() {

 }
 public Person(Long id, String name, byte gender, short age, long salary, double weight, char level, boolean adult,
 Date birthday, String[] hobbies, List dogs, Map address) {
 super();
 this.id = id;
 this.name = name;
 this.gender = gender;
 this.age = age;
 this.salary = salary;
 this.weight = weight;
 this.level = level;
 this.adult = adult;
 this.birthday = birthday;
 this.hobbies = hobbies;
 this.dogs = dogs;
 this.address = address;
 }


 public Long getId() {
 return id;
 }
 public void setId(Long id) {
 this.id = id;
 }
 public String getName() {
 return name;
 }
 public void setName(String name) {
 this.name = name;
 }
 public byte getGender() {
 return gender;
 }
 public void setGender(byte gender) {
 this.gender = gender;
 }
 public short getAge() {
 return age;
 }
 public void setAge(short age) {
 this.age = age;
 }
 public long getSalary() {
 return salary;
 }
 public void setSalary(long salary) {
 this.salary = salary;
 }
 public double getWeight() {
 return weight;
 }
 public void setWeight(double weight) {
 this.weight = weight;
 }
 public char getLevel() {
 return level;
 }
 public void setLevel(char level) {
 this.level = level;
 }
 public boolean isAdult() {
 return adult;
 }
 public void setAdult(boolean adult) {
 this.adult = adult;
 }
 public Date getBirthday() {
 return birthday;
 }
 public void setBirthday(Date birthday) {
 this.birthday = birthday;
 }

 // 處理序列化枚舉類型,默認的值是序列化枚舉值字符串,而不是枚舉綁定的索引或者文本
 @JSONField(name = "edu")
 public int getEdu(){
 return education.getIndex();
 }

 @JSONField(name = "edu")
 public void setEdu(int index){
 this.education = Education.getEnum(index);
 }

 @JSONField(serialize = false)
 public Education getEducation() {
 return education;
 }

 @JSONField(serialize = false)
 public void setEducation(Education education) {
 this.education = education;
 }


 public String[] getHobbies() {
 return hobbies;
 }
 public void setHobbies(String[] hobbies) {
 this.hobbies = hobbies;
 }
 public List getDogs() {
 return dogs;
 }
 public void setDogs(List dogs) {
 this.dogs = dogs;
 }
 public Map getAddress() {
 return address;
 }
 public void setAddress(Map address) {
 this.address = address;
 }
}

TestController

package com.mengdee.manage.controller;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.DoubleSerializer;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
import com.mengdee.manage.entity.Address;
import com.mengdee.manage.entity.Dog;
import com.mengdee.manage.entity.Education;
import com.mengdee.manage.entity.Person;

@Controller
public class TestController {
 private static SerializeConfig serializeConfig = new SerializeConfig(); 
 static {
 serializeConfig.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss")); 
 serializeConfig.put(Double.class, new DoubleSerializer(new DecimalFormat("0.00")));
 }


 @RequestMapping("/index")
 public String index(){
 return "index";
 }


 // javabean to object
 @RequestMapping("/json")
 @ResponseBody
 public Object json(){
 Person person = new Person();
 person.setId(1L);
 person.setName("mengdee");
 person.setAge((short) 18);

 // 
 /*
 {
 "birthday": null, 
 "weight": 0, 
 "dogs": null, 
 "adult": false, 
 "hobbies": null, 
 "education": null, 
 "id": 1, 
 "level": "", 
 "address": null, 
 "age": 18, 
 "name": "mengdee", 
 "gender": 0, 
 "salary": 0
 }
 */
 Object personJson = JSON.toJSON(person);
 return personJson;
 }

 // javabean to string
 @RequestMapping("/json2")
 @ResponseBody
 public String json2(){
 Person person = new Person();
 person.setId(1L);
 person.setName("mengdee");
 person.setAge((short) 18);

 // 使用該方式值為null的經測試不出來,已經配置了WriteMapNullValue
// "{"adult":false,"age":18,"gender":0,"id":1,"level":"","name":"mengdee","salary":0,"weight":0.0}"
 String jsonString = JSON.toJSONString(person);
 return jsonString;
 }

 @RequestMapping("/json3")
 @ResponseBody
 public Object json3(){
 Person person = new Person();
 person.setId(1L);
 person.setName("mengdee");
 person.setAge((short) 18);
 person.setBirthday(new Date()); 

 Object personJson = JSON.toJSON(person); // JSON.toJSON(person)默認是毫秒數"birthday":1495073314780,

// 使用serializeConfig序列號配置對日期格式化
// "{"birthday":"2017-05-18 10:19:55","weight":0.0,"adult":false,"id":1,"level":"","age":18,"name":"mengdee","gender":0,"salary":0}"
 String jsonString = JSON.toJSONString(personJson, serializeConfig);
 return jsonString;
 }


 @RequestMapping("/json4")
 @ResponseBody
 public Object json4(){
 Person person = new Person();
 person.setId(1L);
 person.setName("mengdee");
 person.setAge((short) 18);
 person.setBirthday(new Date()); 
 person.setEducation(Education.UNIVERSITY); // 枚舉

 String[] hobbies = {"讀書", "旅游"};
 person.setHobbies(hobbies);

 Dog dog1 = new Dog(1L, "dog1", (short)1);
 Dog dog2 = new Dog(2L, "dog2", (short)2);
 List dogs = new ArrayList<>();
 dogs.add(dog1);
 dogs.add(dog2);
 person.setDogs(dogs);

 Address address1 = new Address(1l, "上海浦東新區");
 Address address2 = new Address(2l, "上海寶山區");
 Map addressMap = new HashMap<>();
 addressMap.put(address1.getId() + "", address1);
 addressMap.put(address2.getId() + "", address2);
 person.setAddress(addressMap);



 Object personJson = JSON.toJSON(person);

 return personJson;
 }

 @RequestMapping("/json5")
 @ResponseBody
 public String json5(){
 Dog dog1 = new Dog(1L, "dog1", (short)1);
 Dog dog2 = new Dog(2L, "dog2", (short)2);
 List dogs = new ArrayList<>();
 dogs.add(dog1);
 dogs.add(dog2);

 // List -> JSON
 String jsonString = JSON.toJSONString(dogs, false);
 System.out.println(jsonString);

 // JSON -> List 
 List parseArray = JSON.parseArray(jsonString, Dog.class);
 for (Dog dog : parseArray) {
 System.out.println(dog);
 }

 Map map = new HashMap(); 
 map.put("dog1",new Dog(1L, "dog1", (short)1)); 
 map.put("dog2",new Dog(2L, "dog2", (short)2)); 
 map.put("dog3",new Dog(3L, "dog3", (short)3)); 

 // Map -> JSON
 String mapJsonString = JSON.toJSONString(map,true); 
 System.out.println(mapJsonString); 

 // JSON -> Map 
 @SuppressWarnings("unchecked")
 Map map1 = (Map)JSON.parse(mapJsonString); 
 for (String key : map1.keySet()) { 
 System.out.println(key + ":" + map1.get(key)); 
 }

 // Array -> JSON
 String[] hobbies = {"a","b","c"}; 
 String hobbiesString = JSON.toJSONString(hobbies,true); 
 System.out.println(hobbies); 

 // JSON -> Array
 JSONArray jsonArray = JSON.parseArray(hobbiesString); 
 for (Object o : jsonArray) { 
 System.out.println(o); 
 } 
 System.out.println(jsonArray); 
 return jsonString;
 }
}

Swagger集成

第一步:引入相關依賴


 io.springfox
 springfox-swagger2
 2.6.1
 compile


 com.fasterxml.jackson.core
 jackson-databind
 2.6.6

第二步:Swagger信息配置

SwaggerConfig.java

@Configuration
@EnableWebMvc
@EnableSwagger2
public class SwaggerConfig {
 @Bean
 public Docket customDocket() {
 Docket docket = new Docket(DocumentationType.SWAGGER_2);
 docket.apiInfo(apiInfo());
 docket.select().apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class));
 docket.select().paths(PathSelectors.regex("/api/.*")).build();

 return docket;
 }

 private ApiInfo apiInfo() {
 Contact contact = new Contact("小明", "http://www.baidu.com", "baidu@163.com");
 return new ApiInfo("API接口", //大標題 title
 "API接口", //小標題
 "0.0.1", //版本
 "www.baidu.com",//termsOfServiceUrl
 contact,//作者
 "API接口",//鏈接顯示文字
 "http://www.baidu.com"http://網站鏈接
 );
 }
}

注意:因SwaggerConfig這個類配置了注解,所以這個類必須被掃描到,即該類一定包含在context:component-scan中。

第三步:在類、方法、參數上使用注解

@Controller
@RequestMapping("/api/v1")
@Api(description = "API接口")
public class ApiController {
 @ApiOperation(value = "用戶登錄", notes = "用戶登錄接口")
 @ApiResponses({
 @ApiResponse(code = 0, message = "success"),
 @ApiResponse(code = 10001, message = "用戶名錯誤", response = IllegalArgumentException.class),
 @ApiResponse(code = 10002, message = "密碼錯誤")
 })
 @RequestMapping(value = "/user/login", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8;"})
 @ResponseBody
 public String login(@ApiParam(name = "username", value = "用戶名", required = true) @RequestParam String username,
  @ApiParam(name = "password", value = "密碼", required = true) @RequestParam String password){
 return "{'username':'" + username + "', 'password':'" + password + "'}";
 }


 @ApiImplicitParams({
 @ApiImplicitParam(paramType = "header", name = "phone", dataType = "String", required = true, value = "手機號"),
 @ApiImplicitParam(paramType = "query", name = "nickname", dataType = "String", required = true, value = "nickname", defaultValue = "雙擊666"),
 @ApiImplicitParam(paramType = "path", name = "platform", dataType = "String", required = true, value = "平臺", defaultValue = "PC"),
 @ApiImplicitParam(paramType = "body", name = "password", dataType = "String", required = true, value = "密碼")
 })
 @RequestMapping(value = "/{platform}/user/regist", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8;"})
 @ResponseBody
 public String regist(@RequestHeader String phone, @RequestParam String nickname, @PathVariable String platform, @RequestBody String password){
 return "{'username':'" + phone + "', 'nickname':'" + nickname + "', 'platform': '" + platform + "', 'password':'"+password+"'}";
 }

 @RequestMapping(value = "/user/list", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8;"})
 @ResponseBody
 public String getUserList(Pager pager){
 return "[{'id': "+pager.getPage()+", 'username': 'zhangsan"+pager.getSize()+"'}]";
 }

 @RequestMapping("/docs")
 @ApiIgnore
 public String test(){
 return "api-docs";
 }
}

Pager

public class Pager {
 @ApiModelProperty(value = "頁碼", required = true)
 private int page;
 @ApiModelProperty(value = "每頁條數", required = true)
 private int size;

 public Pager() {
 }

 public int getPage() {
 return page;
 }

 public void setPage(int page) {
 this.page = page;
 }

 public int getSize() {
 return size;
 }

 public void setSize(int size) {
 this.size = size;
 }
}

常用注解:

  • @Api(description = “接口類的描述”)
  • @ApiOperation(value = “接口方法的名稱”, notes = “備注說明”)
  • @ApiParam(name = “參數名稱”, value = “備注說明”, required = 是否必須):標注在方法的參數上 用于描述參數的名稱、備注、是否必須等信息
  • @ApiImplicitParam(paramType = “query”, name = “password”, dataType = “String”, required = true, value = “密碼”, defaultValue = “123456”)用于描述方法的參數,標注在方法上,和@ApiParam功能一樣,只是標注的位置不同而已
         .paramType:參數類型,即參數放在哪個地方
                .   header–>請求參數的獲取:@RequestHeader,參數放在請求頭
                 .   query–>請求參數的獲取:@RequestParam,參數追加在url后面
                 .   path(用于restful接口)–>請求參數的獲取:@PathVariable
                 .   body 使用@RequestBody接收數據 POST有效,參數放在請求體中
                 .    form
        .name:參數名
        .dataType:參數的數據類型
        .required:參數是否必須傳
        .value:參數的描述
        .defaultValue:參數的默認值
  • @ApiImplicitParams: 用于包含多個@ApiImplicitParam
  • @ApiResponse(code = 0, message = “success”),
         .code:響應碼,例如400
         .message:信息,一般是對code的描述
         .response:拋出異常的類
  • @ApiModel:描述一個Model的信息(這種一般用在post創建的時候,使用@RequestBody這樣的場景,請求參數無法使用@ApiImplicitParam注解進行描述的時候)
         .@ApiModelProperty:描述一個model的屬性
                  .   position 允許在模型中顯式地排序屬性。
                  .   value 參數名稱
                  .   required 是否必須 boolean
                  .   hidden 是否隱藏 boolean
                  .   allowableValues = “range[0, 1]” 一般用于指定參數的合法值
  • @ApiIgnore:用于或略該接口,不生成該接口的文檔

第四步:訪問/v2/api-docs

在瀏覽器上訪問http://localhost:8080/工程名稱/v2/api-docs 如果有json內容,證明正常

Spring MVC+FastJson+Swagger集成的完整實例教程

第五步:下載swagger-ui

從github上下載https://github.com/swagger-api/swagger-ui,注意這里要選擇下載v2.2.10(https://github.com/swagger-api/swagger-ui/tree/v2.2.10 (本地下載)),大于這個版本的集成方式不一樣。

集成方法:將v2.2.10下的dist目錄下的所有文件放到自己工程中靜態文件中,并使用下面代碼覆蓋掉index.html中的腳本部分

第六步:訪問上面修改的那個index.html
http://localhost:8080/工程名稱/static/third-party/swagger-ui/index.html

注意:因要訪問靜態資源,使用springmvc請確保靜態資源能夠被訪問到,如果不能訪問請做如下配置:

1、 在Spring的配置文件中增加默認的servlet處理器


2、 在web.xml中增加要過濾的靜態文件



 default
 *.js
 *.css
 /assets/*"
 /images/*

Spring MVC+FastJson+Swagger集成的完整實例教程

示例項目代碼結構:

Spring MVC+FastJson+Swagger集成的完整實例教程

完整示例Demo下載地址: http://xiazai.jb51.net/201804/yuanma/platform-springmvc-webapp(jb51.net).rar

其他

關于spring-servlet.xml 和 applicationContext.xml

SpringMVC 提供了兩種配置文件 spring-servlet.xml 、 applicationContext.xml
spring-servlet.xml 是Controller級別的,作用范圍是控制層,默認的名字是【servlet-name】-servlet.xml
默認是放在WEB-INF/目錄下,SpringMVC會自動加載,也可以在web.xml中配置它的位置


 spring-mvc
 org.springframework.web.servlet.DispatcherServlet
  
 contextConfigLocation 
 /WEB-INF/spring-servlet.xml 
 
 1

一般在spring-servlet.xml中配置一些和控制器相關的配置,如視圖解析、靜態資源文件的映射、返回結果的解析等

視圖解析

  • org.springframework.web.servlet.view.UrlBasedViewResolver
  • tiles3: org.springframework.web.servlet.view.tiles3.TilesConfigurer
  • springMVC: org.springframework.web.servlet.view.InternalResourceViewResolver,
  • shiro: org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor
  • 上傳 org.springframework.web.multipart.commons.CommonsMultipartResolver,

靜態資源映射





 

org.springframework.context.support.ResourceBundleMessageSource

返回結果的解析

  • FastJson: com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter

3、applicationContext.xml 是系統級別的配置,作用范圍是系統上下文,它的初始化需要放到 web.xml 中的context-param中配置


 contextConfigLocation
 classpath:conf/spring/spring-*.xml

4、 關于applicationContxt.xml,一般是按照功能拆成多個配置文件如:

  • - applicationContxt-base.xml // 基礎
  • - applicationContxt-redis.xml // redis相關配置
  • - applicationContxt-shiro.xml // shiro 相關配置
  • - applicationContxt-dao.xml // 數據庫相關配置
  • - applicationContxt-xxx.xml // xxx

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對創新互聯的支持。


分享題目:SpringMVC+FastJson+Swagger集成的完整實例教程
本文網址:http://www.xueling.net.cn/article/iigepo.html 主站蜘蛛池模板: 阳茎伸入女人阳道视频免费 | 欧美亚洲国语精品一区二区 | 欧美色蜜桃97 | 国产一区二区在线不卡 | 亚洲欧洲日产国产最新 | 91爱插插| 亚洲网站在线免费观看 | 久久久久青草 | 91五月色国产在线观看 | 色妞永久免费视频 | 国产精品高清视亚洲一区二区 | 亚洲人线精品午夜 | 精品精品精品 | 免费看黄色毛片网站播放 | 无码精品国产一区二区三区免费 | 亚洲sss综合天堂久久 | 蜜桃www视频高清在线观看 | 日韩精品免费一线在线观看 | 福利精品 | 亚洲精品AV午夜一区二区三区 | 军歌嘹亮在线观看 | 成年人午夜视频 | 伊人精品视频在线观看 | 欧美亚洲91 | 久久99久久99精品免观看 | aaa在线观看| 二级特黄绝大片免费视频大片 | 精品国产1区2区 | 国产亚洲人成无码网在线观看 | 国产成人无码A在线观看不卡 | 91社区在线观看 | 亚洲国产精品一区二区久 | 无线乱码一二三区免费看 | 少妇高潮灌满白浆毛片免费看 | 美女黄a一级视频 | 美景之屋3在线观看 | 成年人免费网站在线观看 | 五月丁香六月综合AV | 无码欧美熟妇人妻影院 | 丰满少妇好紧多水视频 | 一边捏奶头一边高潮视频 |