在我的REST API中,每当用户尝试访问不存在的资源时,我都会返回404。EntityResponse字符集编码错误
但是,Firefox不显示“404错误”页面,但抱怨字符编码。
这是我的控制器代码:
@RequestMapping("/countries/{countryId}")
public ResponseEntity<?> country(@PathVariable Integer countryId) {
return countriesService.getCountry(countryId);
}
其中要求从服务实体此方法:
public ResponseEntity<?> getCountry(Integer countryId) {
Country country = countryDAO.findById(countryId);
if (country == null)
return ResponseEntity.notFound().build();
return ResponseEntity.ok(new DetailedCountryJson(country));
}
DetailedCountryJson是一个简单的JSON对象。所以,当我访问
localhost:8080/countries/1
我得到有关这个国家的JSON,但是当我试图用一个id这是不是在数据库中,我得到
它说
未声明纯文本文档的字符编码。如果文档包含US-ASCII范围之外的字符,则该文档将在某些浏览器配置中呈现乱码文本。文件的字符编码需要在传输协议中声明,或者文件需要使用字节顺序标记作为编码签名。
你能转换图像以英文文本? –
@RickS我在译文中加入了翻译 – user2436719