기본 부분
1. Fastjson 소개
Fastjson은 Java 객체를 JSON 표현으로 변환하는 데 사용할 수있는 Java 라이브러리입니다. 또한 JSON 문자열을 동등한 Java 객체로 변환하는 데 사용될 수 있습니다. 가장 빠른 전환 속도 여야하며 거의 프로젝트의 표준 구성이되었습니다 (FASTJSON은 일반적으로 AJAX 요청 및 인터페이스 개발이 필요할 때 Jackson 대신 사용됩니다).
github : https://github.com/alibaba/fastjson (로컬 다운로드)
특성:
주요 기능 :
2. FastJson API
FastJson API 항목 클래스는 com.alibaba.fastjson.json입니다. 공통 직렬화 작업은 JSON 클래스의 정적 메소드로 직접 완료 할 수 있습니다.
// JSONOBJECT 또는 JSONARRAY 공개 정적 최종 개체 구문 분석 (문자열 텍스트)으로 JSON 텍스트를 구문 분석합니다. // JSONOBJECT 공개 정적 최종 최종 JSONOBJECT PARSEOBJECT (String Text)에 JSON 텍스트를 구문 분석합니다. // javabean public static final <t> t parseobject (문자열 텍스트, 클래스 <t> clazz)로 JSON 텍스트를 구문 분석합니다. // JSONARRAY 공개 정적 최종 최종 JSONARRAY PARSEARRAY (문자열 텍스트)에 JSON 텍스트를 구문 분석합니다. // JSON 텍스트를 Javabean Collection에 구문 분석 공개 정적 최종 <T> List <T> ParsEarray (문자열 텍스트, 클래스 <T> Clazz); // JSON 텍스트로 javabean을 직렬화 공개 정적 최종 문자열 tojsonstring (Object Object); // javabean을 형식화 된 jsonstring으로 직렬화합니다 (Object Object, Boolean PrettyFromat); // javabean을 jsonobject 또는 jsonarraypublic 정적 최종 개체 tojson으로 변환합니다.
JSONARRAY : <bood> 목록에 해당합니다
jsonobject : map <string, object>에 해당합니다
SerializeConfig : 일부 필드 (날짜, 열거 등) 형식과 같은 직렬화 프로세스 중 일부 직렬화 프로세스에 대한 특수 구성입니다.
SerializeWriter : StringBuffer와 동일합니다
SerializerFeature 속성 :
실용적인 부분
1. pom.xml에 Spring MVC 및 FastJson 의존성을 소개합니다
<project xmlns = "http://maven.apache.org/pom/4.0.0"xmlns : xsi = "http://www.w3.org/2001/xmlschema-instance"xsi : schemalocation = "http://maven.apache.org/pom/0.0.0.0 http://maven.apache.org/maven-v4_0_0.xsd "> <modelversion> 4.0.0 </modelversion> <groupid> com.mengdee </groupid> <artifactid> Platform-Springmvc-webapp </artifactid> war </packaging> <버전> 0.0.1-shot </version> <NAINE> Platform-Springmvc-webapp Maven WebApp </name> <Url> http://maven.apache.org </url> <properties> <project.build.sourceencoding> utf-8 </project.build.sourceencoding> <junit.version> 3.8.1 </junit <log4j.version> 2.5 </log4j.version> <jstl.version> 1.2 </jstl.version> <spring.version> 4.2.3.3.3. release </spring.version> <fastjson.version> 1.2.32 </fastjson.version> </properties> <pectient> <GroupId> Junit> <artifactid> junit </artifactid> <bersion> 3.8.1 </version> <copo> </scope> </spectency> <pectionement> <groupid> javax.servlet </groupid> <artifactid> jstl </artifactid> <version> $ {jstl.version} </inpendency> <! <groupid> org.springframework </groupid> <artifactid> spring-webmvc </artifactid> <버전> $ {spring.version} </version> </fectionency> <prectionency> <groupId> org.sprameframwork </groupid> <artifactid> spring-core </artifactid> $ {spring <pectionency> <groupId> org.springframework </groupid> <artifactid> spring-context </artifactid> <버전> $ {spring.version} </version} </version} </version} </dependency> <groupId> org.springframework </groupIds> <artifactid> spring-context-support </artifactid> <버전> $ {spring.version} </version} </version} </version> <pectionency> <groupid> org.springframework </groupid> <artifactid> spring-jdbc </artifactid> <version> $ {spring.version} </version> </dependency> <groupjson <artibaba <artifactid> <artifactid> <버전> $ {fastjson.version} </version> </dependency> </fectionements> <!-Aliyun Mirror 사용-> <repository> <id> aliyun </id> <name> aliyun </name> <url> http://maven.aliyun.com/nxus/cont/cont/cont/cont/cont/cont/cont/cont/ </repository> </repository> </repository> </repository> </repository> <finalName> Platform-Springmvc-webapp </finalName> </build> </project>2. web.xml 구성
<! docType Web-App Public "-// Sun Microsystems, Inc.//dtd 웹 응용 프로그램 2.3 // en" "http://java.sun.com/web-app_2_3.dtd"> <web-App> <display-name> archetype </display-name> <Param-value> classPath : conf/spring/spring-*. xml </param-value> </context-param> <liseger> <설명> 스프링 리스너 </desister> <liseer-class> org.springframework.web.context.contextloderListener </larkes-class> <servlet> <servlet-name> spring-nome> <Servlet-Class> org.springframework.web.servlet.dispatcherServlet </servlet-class> <init-param> <param-name> contextConfigLocation </param-value> /web-inf/spring-servlet.xml </aitraram> </init-param> </eloth-param> </servlet> <servlet-mapping> <servlet-mapping> <servlet-name> spring-mvc </servlet-name> <Url-pattern>/</url-pattern> </servlet-mapping> <filter-name> tatorialEncodingFilter </filter-name> <filter-class> org.springframework.web.filter.characterencodingfilter </filter-class> <init-param> incoding </param-name> <param-value> utf-8 </param-value> <init-param> <init-param> force-name </param-name> <Param-value> true </param- value> </init-param> </filter> <filter-mapping> <filter-name> characterencodingfilter </filter-name> <Url-pattern>/*</url-pattern> </filter-mapping> <ERCOL-file-file>/index.jsp </welcome-file> <Error-Code> 404 </error-code> <위치>/index.jsp </location> </error-page> </web-app>
3. Spring-Servlet.xml을 구성하십시오
<? xml 버전 = "1.0"alcoding = "utf-8"?> <beans xmlns = "http://www.springframework.org/schema/beans"xmlns : xsi = "http://ww.w.w3.org/2001/xmlschema-instance" xmlns : p = "http://www.springframework.org/schema/p"xmlns : context = "http://www.springframework.org/schema/context"xmlns : mvc = "http://www.springframwork.org/schema/mvc.org/schema/mvc. xsi : schemalocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/sprging-conxt-4.2.xsd <context : component-scan base-package = "com.mengdee.manage.manage.controller"/> <bean id = "ViewResolver"> <property name = "prefix"value = "/"> </property> <!-뷰 파일의 접두사-> <속성 이름 = "toldix"value = ". jsp"> <! you here in here jsp a here a here? 속도 및 기타 물건을 사용할 수 있습니다-> <property name = "viewclass"value = "org.springframework.web.servlet.view.jstlview"> </property> </bean> <!-시작 스프링 MVC 주석 기능을 시작하여 요청 및 주석 Pojos --> MVC : MVC : MVC : MVC : 메시지를 작성하십시오. Register-defaults = "true"> <!-원래 Jackson Support를 대체하도록 FastJson을 구성합니다-> <ean> <property name = "supportedMediAtypes"> <list> <value> text/html; charset = utf-8 <value> application/json </value> </list> </property> <value </value </value </value> <value </value> 키를 출력 할 때의 인용, true-> <alue> writemapnullvalue </value> <!-널 값을 가진 필드를 출력할지 여부-> <!-<alue> disablecircularReferendEtect </value> <value> writedateusedateformat </value> value> value </value>가 널리 사용되는 경우 writedateusedateformat </value> value> <value> WritenUllNumberAszero </value> 숫자 필드가 NULL 인 경우 출력은 0이면 NULL <AULL> WRITENULLBOOLEANASFALSE </value> 부울 필드가 NULL, 출력이 False, NULL> LISTENULLLLISTASEMPTY </value> 목록 필드는 NULL이고, 출력은 [], </value-> </bean> </bean> </mvc : message-converters> </mvc : 주석 구동> </beans>
4. 자바
교육 : 교육 (열거 수업)
package com.mengdee.manage.entity; import java.util.hashmap; import java.util.map;/** * 교육 * @author 관리자 */public enum Education ( "kindergarten", 1), 초등학교 ( "초등학교", 2), junior_middle ( "Junior_middle", 3), 3), 3). 대학 ( "대학", 5), 대학 ( "대학", 6); 개인 정적 최종지도 <정수, 교육> 교육_map = New Hashmap <Integer, Education> (); 정적 {for (교육 교육 : Education.values ()) {Education_map.put (Education.getIndex (), Education); }} 개인 문자열 텍스트; 개인 INT 인덱스; 사립 교육 (문자열 텍스트, int index) {this.text = 텍스트; this.index = index; } public String getText () {return 텍스트; } public void setText (문자열 텍스트) {this.text = 텍스트; } public int getIndex () {return index; } public void setIndex (int index) {this.index = index; } 공공 정적 교육 getEnum (정수 지수) {return education_map.get (index); }}사람:
패키지 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 long id; 개인 문자열 이름; 개인 바이트 성별; // 젠더 1 : 남성 2 : 여성 사적 단기기; // 연령대 연봉 연봉; // 급여 개인 이중 무게; // 무게 개인 숯 수준; // 개인 부울 성인 등급; // 성인 개인 데이트 생일 여부; // 생일 사립 교육 교육; // 교육 자격 개인 문자열 [] 취미; // 취미 개인 목록 <Dog> 개; // 애완견 개인지도 <문자열, 개체> 주소; // 주소 // 주석을 사용하여 @jsonfield (serialize = false) serialize 개인 목록 <boodge> obj = new ArrayList <> (); 공개 사람 () {} 공개 사람 (긴 ID, 문자열 이름, 바이트 성별, 단기간, 긴 급여, 이중 무게, 숯 수준, 부울 성인, 날짜 생일, 문자열 [] 취미, 목록 <dog> 개,지도 <문자열, 개체> 주소) {super (); this.id = id; this.name = 이름; this.gender = 성별; this.age = age; this.salary = 급여; this.weight = weight; this.level = 레벨; this.adult = 성인; this.birthday = 생일; this.hobbies = 취미; this.dogs = 개; address = 주소; } public long getId () {return id; } public void setId (long id) {this.id = id; } public String getName () {return name; } public void setName (문자열 이름) {this.name = 이름; } public byte getgender () {return gender; } public void setgender (바이트 성별) {this.gender = 성별; } public short getage () {return age; } public void setage (단기 연령) {this.age = age; } public long getSalary () {반환 급여; } public void setSalary (긴 급여) {this.salary = 급여; } public double getweight () {return weight; } public void setweight (이중 무게) {this.weight = weight; } public char getLevel () {리턴 레벨; } public void setLevel (char level) {this.level = level; } public boolean isadult () {return 성인; } public void setAdult (부울 성인) {this.adult = 성인; } 공개 날짜 getBirthday () {return birthday; } public void setbirthday (날짜 생일) {this.birthday = 생일; } // 직렬화 된 열거 유형을 처리하면, 기본값은 열거 된 바인딩 인덱스 또는 텍스트 @jsonfield (name = "edu") 대신 직렬화 된 열거 값 문자열입니다. public int getedu () {return education.getIndex (); } @jsonfield (name = "edu") public void setedu (int index) {this.education = Education.getenum (색인); } @jsonfield (Serialize = false) 공공 교육 getEducation () {반환 교육; } @jsonfield (Serialize = false) public void seteducation (교육 교육) {this.education = Education; } public String [] gethobbies () {return 취미; } public void sethobbies (String [] Hobbies) {this.hobbies = 취미; } public list <dog> getDogs () {반환 개; } public void setDogs (list <dog> dogs) {this.dogs = dogs; } public map <string, object> getAddress () {반환 주소; } public void setAddress (map <string, 객체> 주소) {this.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.springframwork.stereotyp.controller; org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.responsebody; import com.alibaba.fastjson.json; import com.alibaba.astjson.jsonarray; import com.alibaba.fastjson.serializer.doubleserializer; 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 com.mengdee.manage.entity.person; @controllerPublic 클래스 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 ((짧은) 18); /// * { "생일": null, "weight": 0, "dogs": null, "성인": 거짓, "취미": null, "null": null, "id": 1, "level": "", "주소": "Age": "이름": "Mengdee", "Gender": 0 "(0} */ 대상인); Return Personjson; } // javabean to string @requestmapping ( "/json2") @ResponseBody public String json2 () {person person = new person (); person.setid (1l); person.setName ( "mengdee"); person.setage ((짧은) 18); // null 값을 사용하면 테스트 할 수 없습니다. <value> writemapnullvalue </value> // "{"성인 ": 거짓,"나이 ": 18,"성별 ": 0,"id ": 1,"level ":" ","name ":"mengdee ","Salary ": 0,"weight ": jsonstring = json.tojsonstring (person); jsonstring을 반환합니다. } @RequestMapping ( "/json3") @ResponseBody public Object JSON3 () {person person = new person (); person.setid (1l); person.setName ( "mengdee"); person.setage ((짧은) 18); person.setbirthday (새 날짜 ()); Object Personjson = json.tojson (사람); // json.tojson (person) 기본값 "생일": 1495073314780, // SerializeConfig 일련 번호를 사용하여 날짜에 대한 형식을 구성하여 "{"생일 ":"2017-05-18 10:19:55 ","무게 ": 0.0,"성인 ": 거짓,"ID ":"1, "레벨": "", "나이": 18, "이름": "mengdee", "gender": 0, "Salary": 0} "String Jsonstring = json.tojsonstring (personjson, serializeconfig); jsonstring을 반환합니다. } @RequestMapping ( "/json4") @ResponseBody public Object JSON4 () {person person = new person (); person.setid (1l); person.setName ( "mengdee"); person.setage ((짧은) 18); person.setbirthday (새 날짜 ()); person.seteducation (교육 .university); // 열거 문자열 [] 취미 = { "읽기", "관광"}; 사람. Sethobbies (취미); Dog 1 = New Dog (1L, "Dog1", (Short) 1); Dog2 = New Dog (2L, "dog2", (Short) 2); 목록 <dog> dogs = new ArrayList <> (); dogs.add (dog1); dogs.add (dog2); person.setdogs (개); 주소 주소 1 = 새로운 주소 (1L, "상하이 푸동 뉴 디스트릭트"); 주소 주소 2 = 새로운 주소 (2L, "상하이 바오 산 지구"); Map <String, Object> addressMap = New Hashmap <> (); addressMap.put (address1.getId () + "", address1); addressMap.put (address2.getId () + "", address2); person.setAddress (주소 map); Object Personjson = json.tojson (사람); Return Personjson; } @requestmapping ( "/json5") @ResponseBody public String json5 () {dog dog1 = new Dog (1L, "dog1", (Short) 1); Dog2 = New Dog (2L, "dog2", (Short) 2); 목록 <dog> dogs = new ArrayList <> (); dogs.add (dog1); dogs.add (dog2); // list <t> -> JSON String jsonstring = json.tojsonstring (dogs, false); System.out.println (jsonstring); // json-> list <T> List <Dog> parsEarray = json.parsearray (jsonstring, dog.class); for (dog dog : parsearray) {System.out.println (개); } map <String, dog> map = new Hashmap <String, dog> (); 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 ( "선택 취소") map <String, dog> map1 = (map <String, dog>) json.parse (mapjsonstring); for (문자열 키 : map1.keyset ()) {system.out.println (key + ":" + map1.get (key)); } // array-> json string [] 취미 = { "a", "b", "c"}; String Hobbiestring = json.tojsonstring (Hobbies, True); System.out.println (취미); // json-> 배열 jsonarray jsonarray = json.parsearray (Hobbiesstring); for (object o : jsonarray) {system.out.println (o); } system.out.println (jsonarray); jsonstring을 반환합니다. }}Swagger 통합
1 단계 : 관련 종속성을 소개합니다
<pectionency> <groupid> io.springfox </groupid> <artifactid> springfox-swagger2 </artifactid> <버전> 2.6.1 </version> <copope> compile </scope> </fexendency> <pelection> <groupid> com.fasterxml.jackson.core </artifactid> jackson-databind> <버전> 2.6.6 </버전> </의존성>
2 단계 : Swagger 정보 구성
SwaggerConfig.java
@configuration@enablewebmvc@enablebsger2public class swaggerconfig {@bean public docket customDocket () {docket docket = new Docket (documentationType.Swagger_2); docket.apiinfo (apiinfo ()); docket.select (). apis (requestHandlersElector.withMethodAntation (apioperation.class)); docket.select (). Paths (pathselectors.regex ( "/api /.")). build (); 반환 도켓; } private apiinfo apiinfo () {contact contact = new Contact ( "Xiao Ming", "http://www.baidu.com", "[email protected]"); New Apiinfo ( "API 인터페이스", // 큰 제목 "API 인터페이스", // 자막 "0.0.1", // 버전 "www.baidu.com", // orderfserviceurl contact, // 저자 "API 인터페이스", // 링크 표시 "http://www.baidu.com"; }}참고 : SwaggerConfig 클래스는 주석을 구성 하므로이 클래스를 스캔해야합니다. 즉, 클래스는 컨텍스트 : 구성 요소 스캔에 포함되어야합니다.
3 단계 : 클래스, 메소드 및 매개 변수에 주석을 사용하십시오
@controller @requestMapping ( "/api/v1") @api (description = "api interface") public class apicontroller {value = "user login", notes = "사용자 로그인 인터페이스") @apiresponses ({@apirsponse (code = 0, message = "success") (@apirsponse = @apirspons = @apirspons = @apirspons = 불법적 인 관계자 (code = 10002, message = "password error")}) @ApirSponse (code = 10002, methoud = "/user/login", method = requestmethod.post, produces = { "application/json; charset = utf-8;"@rapparam (@apiparam (@apiparam) " = true) @requestparam 문자열 사용자 이름, @apiparam (name = "password", vale = "password", required = true) @requestparam 문자열 암호) {return "{ 'username': '" + username + ",'password ':' + password +" '} "; } @apiimplicitparams ({@apiimplicitparam (paramtype = "header", name = "phone", dataType = "String", 필수 = true = value = "mobile number"), @apiimplicitparam (paramtype = "query", nameche ", datatype =" "" "" "" "" "" "" "닉네임" 666 "), @apiimplicitparam (paramtype ="path ", name ="platform ", datatype ="string ", required = value ="platform ", defaultValue ="pc "), @apiimplicitparam ="body ", name ="password ", dataType", valess = "valess"))))))))))) "/{platform}/user/regist", method = requestmethod.post, produces = { "application/json; charset = utf-8;"}) @responsebody public string regist (@requestheader string phone, @requestparam string, @pathvariable 문자열 플랫폼, @RequestBody String Password) {useNENMAME ':' '' '' ' '별명': ' " + 닉네임 +"', '플랫폼': ' + 플랫폼 + ",'비밀번호 ':'" + password + " '}"; } @requestmapping (value = "/user/list", method = requestmethod.get, produces = { "application/json; charset = utf-8;"}) @ResponseBody public String getUserList (Pager Peager) {return "[{ 'id':"+pager.getPage ()+": 'username': 'Zhangsan "+Pager.getSize ()+"'}] "; } @requestmapping ( "/docs") @apiignore public String test () {return "api-docs"; }}휴대용 소형 무선 호출기
Public Class Pager {@apimodelProperty (value = "Page Number", 필수 = true) 개인 int 페이지; @apimodelProperty (value = "페이지 당 숫자", 필수 = true) 개인 int 크기; public Pager () {} public int getPage () {반환 페이지; } public void setPage (int page) {this.page = page; } public int getsize () {return size; } public void setsize (int size) {this.size = size; }}일반적인 주석 :
4 단계 : Access /V2 /API-DOC
브라우저에서 http : // localhost : 8080/project name/v2/api-docs를 방문하십시오. JSON 컨텐츠가 있으면 정상입니다.
5 단계 : 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에서 스크립트 부분을 덮어 씁니다.
<script type = "text/javaScript"> var baseUrl = ""; $ (function () {var url = wind (window.waggertranslator) {wind oncomplete : function (swaggerapi, swaggerui) {if (typeof initoauth == "function") {initoauth ({clientId : "your-client-id", clientsecret : "your-client-secret-required", Realm : "your-appname :"scop-name ",", " {}); }, docexpansion : "none", jsoneeditor : false, apissorter : "alpha", defaultmodelrendering : showrequestheaders : false}); Swaggerclient.apikeyauthorization ( "토큰", "Header"); }); </스크립트> 6 단계 : Index.html 위에서 수정 된 액세스
http : // localhost : 8080/project name/static/static/swagger-ui/index.html
참고 : 정적 자원에 액세스하려면 SpringMVC를 사용하여 정적 자원에 액세스 할 수 있는지 확인하십시오. 액세스 할 수없는 경우 다음 구성을하십시오.
1. 기본 서블릿 프로세서를 스프링 구성 파일에 추가합니다.
<!-필터 정적 자원-> <mvc : 기본 수면 핸들러/>
2. web.xml에서 필터에 정적 파일을 추가하십시오
<!-정적 자원 필터링-> <servlet-mapping> <servlet-name> default </servlet-name> <Url-pattern>*
샘플 프로젝트 코드 구조 :
전체 예제 데모 다운로드 주소 : http://xiazai.vevb.com/201804/yuanma/platform-springmvc-webapp(Vevb.com).rar
다른
Spring-Servlet.xml 및 ApplicationContext.xml 정보
SpringMVC는 두 개의 구성 파일 Spring-Servlet.xml 및 ApplicationContext.xml을 제공합니다
Spring-Servlet.xml은 컨트롤러 레벨이며 동작 범위는 제어 계층입니다. 기본 이름은 [servlet-name] -servlet.xml입니다
기본적으로 Web-Inf/ Directory에 배치됩니다. SpringMVC는 자동으로로드되며 Web.xml에서도 구성 할 수도 있습니다.
<Servlet> <servlet-name> spring-mvc </servlet-name> <servlet-class> org.spramework.web.servlet.dispatcherServlet </servlet-class> <init-param> <param-name> contextConfiglocation </param-name> <param-value>/weprger-servlet.xml </init-param> <load-on-startup> 1 </load-on-startup> </servlet>
일반적으로 일부 컨트롤러 관련 구성은 뷰 해상도, 정적 리소스 파일 매핑, 반환 결과 구문 분석 등과 같은 Spring-Servlet.xml로 구성됩니다.
보기 분석
정적 리소스 매핑
<mvc : 자원 위치 = "/static/"mapping = "/static/<mvc : 자원 위치 ="/images/"mapping ="/static/** "/<mvc : 자원 위치 ="/css/"mapping ="/static/** "/> <mvc : resources location ="/js/"mapping ="/**/** ""/** "" "/**" location = "/html/"mapping = "/static/**"/> <mvc : 자원 위치 = "/upload/"mapping = "/static/**"/>
org.springframework.context.support.resourcebundlemessagesource
결과 분석
3. ApplicationContext.xml은 시스템 수준 구성이며 기능 범위는 시스템 컨텍스트입니다. 초기화는 web.xml의 Context-Param에서 구성해야합니다.
<CENTEXT-PARAM> <Param-Name> ContextConfigLocation </param-name> <Param-value> classPath : conf/spring/spring-*. xml </param-value> </context-param>
4. ApplicationContxt.xml과 관련하여 일반적으로 다음과 같은 기능에 따라 여러 구성 파일로 나뉩니다.
요약
위는이 기사의 전체 내용입니다. 이 기사의 내용에 모든 사람의 연구 나 작업에 대한 특정 참조 가치가 있기를 바랍니다. 궁금한 점이 있으면 의사 소통을 위해 메시지를 남길 수 있습니다. Wulin.com을 지원 해주셔서 감사합니다.