Java SpringBoot在网站上显示unicode问题
我运行了一个springBoot2应用程序来测试Bean从yml文件中获取值,我在yml中设置了中文值,但我在网站上获得了unicode。 我想在网站上显示中文而不是unicode。 为什么会导致这个问题 控制器Java SpringBoot在网站上显示unicode问题,java,spring,spring-boot,unicode,chinese-locale,Java,Spring,Spring Boot,Unicode,Chinese Locale,我运行了一个springBoot2应用程序来测试Bean从yml文件中获取值,我在yml中设置了中文值,但我在网站上获得了unicode。 我想在网站上显示中文而不是unicode。 为什么会导致这个问题 控制器 import com.alice.krislearning.test1.model.Person; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web
import com.alice.krislearning.test1.model.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class PersonController {
@Autowired
Person person;
// @RequestMapping(value = "/person", method = RequestMethod.GET)
@GetMapping("/person")
public String index(){
return person.toString() ;
}
}
豆子
最后,它在网站上显示此输出:
Person(lastname=\u6797,firstname=\u4E16\u660C,name=\u6797\u4E16\u660C,年龄=21,出生=2000/01/12,列表=[1,2,3,a,b,c],map={k1=v1,k2=v2},pet=pet(name=dog,age=11),str1=雙引號會轉譯 哈哈, str2=\u55AE\u5F15\u865F\u4E0D\u8F49\u8B6F\n\u5F15\u865F\u5167\u7684\u6578\u64DA\u539F\u5C01\u4E0D\u52D5\u7684\u8F38\u51FA)
@Component
@ConfigurationProperties(prefix = "person")
@Data
public class Person {
private String lastname;
private String firstname;
private String name;
private String age;
private String birth;
private List<Object> list;
private Map<String,Object> map;
private Pet pet;
private String str1;
private String str2;
}
person:
last-name: 林
first-name: 世昌
name: 林世昌
age: 21
birth: 2000/01/12
boy: false
list:
- 1
- 2
- 3
- a
- b
- c
map: {k1: v1, k2: v2}
pet:
name: dog
age: 11
str1: "雙引號會轉譯\n哈哈"
str2: '單引號不轉譯\n引號內的數據原封不動的輸出'