亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

SpringBoot請(qǐng)求處理之常用參數(shù)注解介紹與源碼分析

 更新時(shí)間:2022年10月08日 14:09:02   作者:Decade0712  
SpringBoot是一種整合Spring技術(shù)棧的方式(或者說是框架),同時(shí)也是簡(jiǎn)化Spring的一種快速開發(fā)的腳手架,本篇讓我們一起學(xué)習(xí)請(qǐng)求處理、常用注解和方法參數(shù)的小技巧

1、注解

@PathVariable:將請(qǐng)求url中的占位符參數(shù)與控制器方法入?yún)⒔壎ㄆ饋恚≧est風(fēng)格請(qǐng)求)

@RequestHeader:獲取請(qǐng)求頭中的參數(shù),通過指定參數(shù) value 的值來獲取請(qǐng)求頭中指定的參數(shù)值

@ModelAttribute:兩種用法

  • 用在參數(shù)上,會(huì)將客戶端傳遞過來的參數(shù)按名稱注入到指定對(duì)象中,并且會(huì)將這個(gè)對(duì)象自動(dòng)加入ModelMap中,便于View層使用
  • 用在方法上,被@ModelAttribute注釋的方法會(huì)在此controller的每個(gè)方法執(zhí)行前被執(zhí)行 ,如果有返回值,則自動(dòng)將該返回值加入到ModelMap中,類似于Junit的@Before

@RequestParam:獲取url中的請(qǐng)求參數(shù)并映射到控制器方法的入?yún)?/p>

@MatrixVariable:獲取矩陣變量

  • 矩陣變量:路徑片段中可以可以包含鍵值對(duì),用分號(hào)進(jìn)行分割,也就是說我們的請(qǐng)求路徑可以表示為/test/pathVaribales;name=decade;age=24
  • 注意,矩陣變量默認(rèn)是關(guān)閉的,需要在自定義的配置類中實(shí)現(xiàn)WebMvcConfigurer接口,并重寫configurePathMatch()方法,將UrlPathHelper對(duì)象的removeSemicolonContent屬性設(shè)置為false,或者或者直接使用@Configuration+@Bean的方式,創(chuàng)建一個(gè)新的bean放到容器中
package com.decade.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.util.UrlPathHelper;
@Configuration(proxyBeanMethods = false)
public class MyMvcConfig implements WebMvcConfigurer {
    // 方式一:實(shí)現(xiàn)WebMvcConfigure接口,重寫指定方法
    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        UrlPathHelper urlPathHelper = new UrlPathHelper();
        // 設(shè)置為false,矩陣變量生效,請(qǐng)求路徑分號(hào)后面的內(nèi)容才不會(huì)被移除
        urlPathHelper.setRemoveSemicolonContent(false);
        configurer.setUrlPathHelper(urlPathHelper);
    }
    // 方式二:直接使用@Configuration+@Bean的方式,創(chuàng)建一個(gè)新的WebMvcConfigure放到容器中,因?yàn)榻涌谟心J(rèn)實(shí)現(xiàn),所以我們只需要重寫指定方法
    @Bean
    public WebMvcConfigurer createWebMvcConfigure() {
        return new WebMvcConfigurer() {
            @Override
            public void configurePathMatch(PathMatchConfigurer configurer) {
                UrlPathHelper urlPathHelper = new UrlPathHelper();
                // 設(shè)置為false,矩陣變量生效,請(qǐng)求路徑分號(hào)后面的內(nèi)容才不會(huì)被移除
                urlPathHelper.setRemoveSemicolonContent(false);
                configurer.setUrlPathHelper(urlPathHelper);
            }
        };
    }
}
  • @CookieValue:獲取cookie中的參數(shù)
  • @RequestBody:獲取請(qǐng)求體中的參數(shù),通過指定參數(shù) value 的值來獲取請(qǐng)求頭中指定的參數(shù)值(POST請(qǐng)求)
  • @RequestAttrible:獲取request域?qū)傩?,也就是獲取當(dāng)前這次請(qǐng)求中的屬性
package com.decade.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class ParameterTestController {
    @RequestMapping(value = "/testPathVariable/{userId}/split/{userName}")
    @ResponseBody
    public Map<String, Object> testPathVariable(@PathVariable("userId") String userId,
        @PathVariable("userName") String userName, @PathVariable Map<String, String> variables) {
        final Map<String, Object> map = new HashMap<>();
        // @PathVariable("userId")可以獲取請(qǐng)求路徑中指定變量,并綁定到對(duì)應(yīng)入?yún)?
        map.put("userId", userId);
        map.put("userName", userName);
        // @PathVariable搭配Map<String, String>可以獲取路徑變量中的所有占位符參數(shù)
        map.put("variables", variables);
        return map;
    }
    @RequestMapping(value = "/testRequestHeader")
    @ResponseBody
    public Map<String, Object> testRequestHeader(@RequestHeader("User-Agent") String userAgent,
        @RequestHeader Map<String, String> headerVariables) {
        final Map<String, Object> map = new HashMap<>();
        // @RequestHeader("User-Agent")可以獲取請(qǐng)求頭中指定參數(shù)
        map.put("userAgent", userAgent);
        // @RequestHeader搭配Map<String, String>可以獲取請(qǐng)求頭中的所有參數(shù)
        map.put("headerVariables", headerVariables);
        return map;
    }
    @RequestMapping(value = "/testRequestParam")
    @ResponseBody
    public Map<String, Object> testRequestParam(@RequestParam("userId") String userId,
        @RequestParam List<String> interest, @RequestParam Map<String, String> variables) {
        final Map<String, Object> map = new HashMap<>();
        // @RequestParam("userId")可以獲取請(qǐng)求URL中指定參數(shù)并綁定到控制器方法入?yún)?
        map.put("userId", userId);
        // 同一個(gè)參數(shù)如果傳入了多個(gè)值,那也可以獲取之后統(tǒng)一放入list列表
        map.put("interest", interest);
        // @RequestParam搭配Map<String, String>可以獲取請(qǐng)求頭中的所有參數(shù)
        map.put("variables", variables);
        return map;
    }
    @RequestMapping(value = "/testCookieValue")
    @ResponseBody
    public Map<String, Object> testCookieValue(@CookieValue("_ga") String ga, @CookieValue("_ga") Cookie cookie) {
        final Map<String, Object> map = new HashMap<>();
        // @CookieValue("_ga")可以獲取指定cookie的value
        map.put("_ga", ga);
        // @CookieValue Cookie可以獲取指定cookie的所有信息,包括name和value等
        map.put("cookie", cookie);
        return map;
    }
    @PostMapping(value = "/testRequestBody")
    @ResponseBody
    public Map<String, Object> testRequestBody(@RequestBody String content) {
        final Map<String, Object> map = new HashMap<>();
        // 獲取post請(qǐng)求表單中的所有參數(shù)
        map.put("content", content);
        return map;
    }
    @GetMapping(value = "/testRequestAttribute")
    public String goToSuccess(HttpServletRequest request) {
        // 向請(qǐng)求域中設(shè)置值
        request.setAttribute("msg", "test");
        request.setAttribute("code", 200);
        // 將請(qǐng)求轉(zhuǎn)發(fā)到/success
        return "forward:/success";
    }
    @GetMapping(value = "/success")
    @ResponseBody
    public Map<String, Object> test(@RequestAttribute("msg") String msg,
        @RequestAttribute("code") int code, HttpServletRequest request) {
        Map<String, Object> map = new HashMap<>();
        // 利用注解獲取request請(qǐng)求域中的值
        map.put("msgFromAnnotation", msg);
        map.put("codeFromAnnotation", code);
        // 從HttpServletRequest對(duì)象中獲取
        map.put("msgFromRequest", request.getAttribute("msg"));
        return map;
    }
    // 矩陣變量的請(qǐng)求方式:http://localhost:8080/car/queryInfo;hobby=game;hobby=music;age=24
    // 注意,矩陣變量必須放在占位符參數(shù)的后邊,使用分號(hào)進(jìn)行分割
    @GetMapping(value = "/car/{path}")
    @ResponseBody
    public Map<String, Object> testMatrixVariable(@MatrixVariable("hobby") List<String> hobby,
        @MatrixVariable("age") int age, @PathVariable("path") String path) {
        Map<String, Object> map = new HashMap<>();
        map.put("age", age);
        map.put("hobby", hobby);
        map.put("path", path);
        return map;
    }
    // 如果請(qǐng)求路徑為http://localhost:8080/car/1;age=39/2;age=23,那么就要使用pathVar來區(qū)分變量名相同的矩陣變量
    @GetMapping(value = "/car/{bossId}/{staffId}")
    @ResponseBody
    public Map<String, Object> testMatrixVariable(@MatrixVariable(value = "age", pathVar = "bossId") int bossAge,
        @MatrixVariable(value = "age", pathVar = "staffId") int staffAge) {
        Map<String, Object> map = new HashMap<>();
        map.put("bossAge", bossAge);
        map.put("staffAge", staffAge);
        return map;
    }
}

然后我們寫一個(gè)html頁(yè)面測(cè)試一下各個(gè)注解

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主頁(yè)</title>
</head>
<body>
Hello World!
<a href="/testPathVariable/001/split/decade" rel="external nofollow" >測(cè)試@PathVariable注解</a>
<br>
<a href="/testRequestHeader" rel="external nofollow" >測(cè)試RequestHeader注解</a>
<br>
<a href="/testRequestParam?userId=001&interest=games&interest=music" rel="external nofollow" >測(cè)試@RequestParam注解</a>
<br>
<a href="/testCookieValue" rel="external nofollow" >測(cè)試@CookieValue注解</a>
<br>
<a href="/testRequestAttribute" rel="external nofollow" >測(cè)試@RequestAttribute注解</a>
<br>
<a href="/car/queryInfo;hobby=game;hobby=music;age=24" rel="external nofollow" >測(cè)試@MatrixVariable注解</a>
<br>
<a href="/car/1;age=39/2;age=23" rel="external nofollow" >測(cè)試@MatrixVariable注解2</a>
<br>
<form action="/testRequestBody" method="post">
    <input name="name" type="hidden" value="decade">
    <input name="age" type="hidden" value="24">
    <input type="submit" value="測(cè)試@RequestBody注解">
</form>
</body>
</html>

2、注解生效相關(guān)源碼分析

學(xué)習(xí)完注解之后,我們不禁疑問,這些注解是怎么將請(qǐng)求中的參數(shù)綁定到控制器方法的入?yún)⑸系哪?/p>

那么接下來,我們就來看一下相關(guān)源碼

首先,我們的目光肯定還是聚焦到DiapatcherServlet這個(gè)類,我們還是找到doDispatch()這個(gè)方法

在使用getHandler()方法獲取到handler之后,它會(huì)去獲取HandlerAdapter

try {
	processedRequest = this.checkMultipart(request);
	multipartRequestParsed = processedRequest != request;
	mappedHandler = this.getHandler(processedRequest);
	if (mappedHandler == null) {
		this.noHandlerFound(processedRequest, response);
		return;
	}
	// 獲取HandlerAdapter 
	HandlerAdapter ha = this.getHandlerAdapter(mappedHandler.getHandler());
	...
	// 執(zhí)行目標(biāo)方法
	mv = ha.handle(processedRequest, response, mappedHandler.getHandler());

我們跟進(jìn)這個(gè)getHandlerAdapter()方法,發(fā)現(xiàn)他是做了一個(gè)遍歷,為當(dāng)前Handler 找一個(gè)適配器 HandlerAdapter,最后返回RequestMappingHandlerAdapter

找到適配器之后,我們做了一系列判斷,接著我們會(huì)使用mv = ha.handle(processedRequest, response, mappedHandler.getHandler())來執(zhí)行目標(biāo)方法,這句代碼會(huì)將我們上面找到的handler、請(qǐng)求request以及響應(yīng)response都傳入其中

我們繼續(xù)深入,發(fā)現(xiàn)斷點(diǎn)走到了RequestMappingHandlerAdapter這個(gè)類下的handleInternal()方法,然后它又調(diào)用了invokeHandlerMethod()

這個(gè)方法中做了如下幾件重要的事情

設(shè)置參數(shù)解析器,我們通過觀察可以看到,這里可用的參數(shù)解析器似乎和我們之前學(xué)習(xí)的參數(shù)注解有關(guān),比如RequestParam、PathVariable等

點(diǎn)擊this.argumentResolvers并一直深入,我們可以發(fā)現(xiàn)它是實(shí)現(xiàn)了HandlerMethodArgumentResolver 這個(gè)接口,這個(gè)接口里面只有2個(gè)方法,也就是說,在這個(gè)接口的27個(gè)實(shí)現(xiàn)類中,我們滿足哪個(gè)參數(shù)解析器的supportsParameter()方法,它就會(huì)調(diào)用對(duì)應(yīng)的resolveArgument()方法來解析參數(shù)

public interface HandlerMethodArgumentResolver {
	// 判斷是否支持此類型參數(shù)
    boolean supportsParameter(MethodParameter parameter);
	// 解析參數(shù)
    @Nullable
    Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception;
}

設(shè)置返回值處理器

我們的方法能返回多少種類型的返回值,也取決于返回值處理器支持哪些類型

執(zhí)行目標(biāo)方法

我們看完上面的參數(shù)解析器和返回值處理器后,直接轉(zhuǎn)到invocableMethod.invokeAndHandle(webRequest, mavContainer, new Object[0]);

跟著斷點(diǎn)深入到ServletInvocableHandlerMethod類下的invokeAndHandle()這個(gè)方法

發(fā)現(xiàn)只要執(zhí)行Object returnValue = this.invokeForRequest(webRequest, mavContainer, providedArgs);之后,斷點(diǎn)就會(huì)跳轉(zhuǎn)到控制器類的具體方法中,也就是說,這里才是真正的方法調(diào)用處

我們來分析一下invokeForRequest()這個(gè)方法

@Nullable
public Object invokeForRequest(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception {
   // 確定目標(biāo)方法的每一個(gè)參數(shù)的值
   Object[] args = this.getMethodArgumentValues(request, mavContainer, providedArgs);
   if (logger.isTraceEnabled()) {
       logger.trace("Arguments: " + Arrays.toString(args));
   }
   //使用反射調(diào)用對(duì)應(yīng)方法
   return this.doInvoke(args);
}

最后,我們發(fā)現(xiàn)參數(shù)的解析是在getMethodArgumentValues()這個(gè)方法進(jìn)行的,它通過一個(gè)for循環(huán),判斷每一個(gè)參數(shù)適合用哪個(gè)解析器來進(jìn)行參數(shù)解析

protected Object[] getMethodArgumentValues(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception {
   // 獲取所有參數(shù)的詳細(xì)信息,包括類型,注解,位置等
   MethodParameter[] parameters = this.getMethodParameters();
   if (ObjectUtils.isEmpty(parameters)) {
       return EMPTY_ARGS;
   } else {
       Object[] args = new Object[parameters.length];
       for(int i = 0; i < parameters.length; ++i) {
           MethodParameter parameter = parameters[i];
           parameter.initParameterNameDiscovery(this.parameterNameDiscoverer);
           args[i] = findProvidedArgument(parameter, providedArgs);
           if (args[i] == null) {
   			// 循環(huán)所有支持的參數(shù)解析器,判斷當(dāng)前參數(shù)被哪種解析器支持,并且把當(dāng)前參數(shù)和解析器當(dāng)作k-v鍵值對(duì)放進(jìn)緩存,方便以后直接取
               if (!this.resolvers.supportsParameter(parameter)) {
                   throw new IllegalStateException(formatArgumentError(parameter, "No suitable resolver"));
               }
               try {
   				// 進(jìn)行參數(shù)解析
                   args[i] = this.resolvers.resolveArgument(parameter, mavContainer, request, this.dataBinderFactory);
               } catch (Exception var10) {
                   if (logger.isDebugEnabled()) {
                       String exMsg = var10.getMessage();
                       if (exMsg != null && !exMsg.contains(parameter.getExecutable().toGenericString())) {
                           logger.debug(formatArgumentError(parameter, exMsg));
                       }
                   }
                   throw var10;
               }
           }
       }
       return args;
   }
}

有興趣的可以繼續(xù)深入,哈哈~

3、Servlet API

如果入?yún)㈩愋褪窍铝兄械哪骋环N

WebRequest、ServletRequest、MultipartRequest、 HttpSession、javax.servlet.http.PushBuilder、Principal、InputStream、Reader、HttpMethod、Locale、TimeZone、ZoneId

對(duì)應(yīng)的參數(shù)解析器就是ServletRequestMethodArgumentResolver

4、復(fù)雜參數(shù)

  • Map、Model:map、model里面的數(shù)據(jù)會(huì)被放在request的請(qǐng)求域 ,類似于request.setAttribute
  • RedirectAttributes( 重定向攜帶數(shù)據(jù))
  • ServletResponse(response)、SessionStatus、UriComponentsBuilder、ServletUriComponentsBuilder、Errors/BindingResult

代碼樣例:

我們寫一個(gè)控制器接口/testModelAndMap,將請(qǐng)求轉(zhuǎn)發(fā)到/testOk這個(gè)接口

@GetMapping(value = "/testModelAndMap")
public String testModelAndMap(Model model, Map<String, Object> map,
    HttpServletRequest request, HttpServletResponse response) {
    map.put("name", "decade");
    model.addAttribute("age", 24);
    request.setAttribute("sex", "man");
    Cookie cookie = new Cookie("n1", "v1");
    cookie.setMaxAge(1);
    response.addCookie(cookie);
    // 將請(qǐng)求轉(zhuǎn)發(fā)到/testOk
    return "forward:/testOk";
}
@GetMapping(value = "/testOk")
@ResponseBody
public Map<String, Object> testOk(HttpServletRequest request) {
    Map<String, Object> map = new HashMap<>();
    map.put("name", request.getAttribute("name"));
    map.put("age", request.getAttribute("age"));
    map.put("sex", request.getAttribute("sex"));
    return map;
}

調(diào)用接口發(fā)現(xiàn),我們?cè)?testModelAndMap接口中放入Map、Model和HttpServletRequest中的參數(shù),在/testOk中也可以取到,這說明這些參數(shù)會(huì)被放在request的請(qǐng)求域中,本次請(qǐng)求完成時(shí)都可以取到

相關(guān)源碼還是DispatcherServlet類下面的doDispatch()

關(guān)鍵點(diǎn)就是根據(jù)參數(shù)類型去找對(duì)應(yīng)的參數(shù)解析器和返回值處理器

  • Map類型:MapMethodProcessor
  • Model類型:ModelMethodProcessor
  • HttpServletRequest:ServletRequestMethodArgumentResolver

注意:ModelAndViewContainer中包含要去的頁(yè)面地址View,還包含Model數(shù)據(jù)

大家可以自己debug一下,不在贅述,否則篇幅太長(zhǎng)了

5、自定義參數(shù)

測(cè)試代碼,先寫2個(gè)實(shí)體類

package com.decade.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Person {
    private String name;
    private int age;
    private Date birth;
    private Pet pet;
}
package com.decade.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Pet {
    private String name;
    private int age;
}

然后寫控制器處理方法

@PostMapping(value = "/savePerson")
@ResponseBody
public Person savePerson(Person person) {
    return person;
}

最后寫一個(gè)HTML頁(yè)面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
Hello World!
<form action="/savePerson" method="post">
    姓名: <input name="name" type="text" value="decade">
    年齡: <input name="age" type="text" value="24">
    生日: <input name="birth" type="text" value="2022/01/01">
    寵物姓名: <input name="pet.name" type="text" value="十年的小狗">
    寵物年齡: <input name="pet.age" type="text" value="1">
    <input type="submit" value="提交保存">
</form>
</body>
</html>

測(cè)試結(jié)果如下,我們發(fā)現(xiàn)簡(jiǎn)單屬性和存在引用關(guān)系的屬性都成功綁定了

對(duì)應(yīng)解析類:ServletModelAttributeMethodProcessor和其父類ModelAttributeMethodProcessor

數(shù)據(jù)綁定核心代碼:

ModelAttributeMethodProcessor類下的resolveArgument()方法

this.bindRequestParameters(binder, webRequest);

binder:web數(shù)據(jù)綁定器,將請(qǐng)求參數(shù)的值綁定到指定的JavaBean里面

WebDataBinder 利用它里面的 Converters 將請(qǐng)求數(shù)據(jù)轉(zhuǎn)成指定的數(shù)據(jù)類型,再次封裝到JavaBean中

GenericConversionService類:getConverter()---->find()

在將請(qǐng)求參數(shù)的值轉(zhuǎn)化為指定JavaBean的對(duì)應(yīng)屬性時(shí),它會(huì)去緩存中尋找是否有合適的Converters轉(zhuǎn)換器,如果沒有就和上面尋找參數(shù)解析器一樣,遍歷所有的轉(zhuǎn)換器,尋找能將request中的類型轉(zhuǎn)換成目標(biāo)類型的轉(zhuǎn)換器

6、類型轉(zhuǎn)換器Converters

有時(shí)候,Spring默認(rèn)提供的converter滿足不了我們的需求

我們就可以直接使用@Configuration+@Bean的方式,自定義一些類轉(zhuǎn)換器,創(chuàng)建一個(gè)新的WebMvcConfigure放到容器中,因?yàn)榻涌谟心J(rèn)實(shí)現(xiàn),所以我們只需要重寫指定方法

package com.decade.config;
import com.decade.pojo.Pet;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration(proxyBeanMethods = false)
public class MyMvcConfig implements WebMvcConfigurer {
    @Bean
    public WebMvcConfigurer createConvert() {
        return new WebMvcConfigurer() {
            @Override
            public void addFormatters(FormatterRegistry registry) {
                registry.addConverter(new Converter<String, Pet>() {
                    @Override
                    public Pet convert(String source) {
                        final String[] split = source.split(",");
                        final Pet pet = new Pet();
                        pet.setName(split[0]);
                        pet.setAge(Integer.parseInt(split[1]));
                        return pet;
                    }
                });
            }
        };
    }

然后寫一個(gè)HTML頁(yè)面進(jìn)行測(cè)試

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
Hello World!
<form action="/savePerson" method="post">
    姓名: <input name="name" type="text" value="decade">
    年齡: <input name="age" type="text" value="24">
    生日: <input name="birth" type="text" value="2022/01/01">
    寵物信息: <input name="pet" type="text" value="十年的小狗,1">
    <input type="submit" value="提交保存">
</form>
</body>
</html>

到此這篇關(guān)于SpringBoot請(qǐng)求處理之常用參數(shù)注解介紹與源碼分析的文章就介紹到這了,更多相關(guān)SpringBoot請(qǐng)求處理內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Apache Calcite進(jìn)行SQL解析(java代碼實(shí)例)

    Apache Calcite進(jìn)行SQL解析(java代碼實(shí)例)

    Calcite是一款開源SQL解析工具, 可以將各種SQL語句解析成抽象語法樹AST(Abstract Syntax Tree), 之后通過操作AST就可以把SQL中所要表達(dá)的算法與關(guān)系體現(xiàn)在具體代碼之中,今天通過代碼實(shí)例給大家介紹Apache Calcite進(jìn)行SQL解析問題,感興趣的朋友一起看看吧
    2022-01-01
  • java HashMap詳解及實(shí)例代碼

    java HashMap詳解及實(shí)例代碼

    這篇文章主要介紹了java HashMap詳解及實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下
    2017-01-01
  • java跳出多重循環(huán)的三種實(shí)現(xiàn)方式

    java跳出多重循環(huán)的三種實(shí)現(xiàn)方式

    文章主要介紹了Java中跳出多重循環(huán)的三種方式:使用`break`配合標(biāo)簽、在布爾表達(dá)式中添加判斷變量、以及使用`try-catch`制造異常,每種方式都有具體的代碼示例,并輸出了相應(yīng)的執(zhí)行結(jié)果
    2025-01-01
  • SpringBoot中使用多線程的方法示例

    SpringBoot中使用多線程的方法示例

    這篇文章主要介紹了SpringBoot中使用多線程的方法示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03
  • 教大家使用java實(shí)現(xiàn)頂一下踩一下功能

    教大家使用java實(shí)現(xiàn)頂一下踩一下功能

    這篇文章主要教大家如何使用java實(shí)現(xiàn)頂一下踩一下功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-02-02
  • SpringBoot導(dǎo)出Excel的四種實(shí)現(xiàn)方式

    SpringBoot導(dǎo)出Excel的四種實(shí)現(xiàn)方式

    近期接到了一個(gè)小需求,要將系統(tǒng)中的數(shù)據(jù)導(dǎo)出為Excel,且能將Excel數(shù)據(jù)導(dǎo)入到系統(tǒng),對(duì)于大多數(shù)研發(fā)人員來說,這算是一個(gè)最基本的操作了,本文就給大家總結(jié)一下SpringBoot導(dǎo)出Excel的四種實(shí)現(xiàn)方式,需要的朋友可以參考下
    2024-01-01
  • java中join方法的理解與說明詳解

    java中join方法的理解與說明詳解

    這篇文章主要給大家介紹了關(guān)于java中join方法的理解與說明的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • 基于Maven pom文件使用分析

    基于Maven pom文件使用分析

    本文詳細(xì)介紹了Maven項(xiàng)目的核心配置文件pom.xml的結(jié)構(gòu)和各個(gè)元素的用途,包括項(xiàng)目基礎(chǔ)信息、依賴管理、倉(cāng)庫(kù)配置、構(gòu)建配置、版本控制、分發(fā)和報(bào)告配置等,幫助讀者全面了解Maven項(xiàng)目的構(gòu)建和管理過程
    2024-12-12
  • java同步之volatile解析

    java同步之volatile解析

    volatile可以說是Java虛擬機(jī)提供的最輕量級(jí)的同步機(jī)制了,了解volatile的語義對(duì)理解多線程的特性具有很重要的意義,下面小編帶大家一起學(xué)習(xí)一下
    2019-05-05
  • spring boot配置ssl實(shí)現(xiàn)HTTPS的方法

    spring boot配置ssl實(shí)現(xiàn)HTTPS的方法

    這篇文章主要介紹了spring boot配置ssl實(shí)現(xiàn)HTTPS的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2019-03-03

最新評(píng)論