package com.mycontroller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.web.util.UriComponents;
import java.net.URI;
@Controller
@RequestMapping(value="/uri")
public class UriController {
@RequestMapping(value="/test")
@ResponseBody
public String test(){
UriComponents uriComponents = UriComponentsBuilder.fromUriString(
"http://example.com/hotels/{hotel}/bookings/{booking}").build();
URI uri = uriComponents.expand("42", "21").encode().toUri();
return uri.toString();
}
}
springMVC入门(五)URI Builder
最新推荐文章于 2022-09-02 15:07:10 发布