我正在使用 MongoDB 和 Spring Boot 2.0.1.RELEASE
。一切似乎都运行良好。我能够使用 MongoRepository 正确执行 CRUD 操作。当我像
@Query(value = "{address.city:?0}")
public List<Hotel> findByCity(String city);
@Query(value = "{address.country:?0}")
public List<Hotel> findByCountry(String country);
当我尝试使用 url localhost:8090/hotels/address/city/Rome
访问数据时,我收到以下响应错误
{
"timestamp": "2018-05-04T04:51:43.549+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Invalid JSON input. Position: 9. Character: '.'.",
"path": "/hotels/address/city/rome"
}
控制台登录如下:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.bson.json.JsonParseException: Invalid JSON input. Position: 9. Character: '.'.] with root cause
org.bson.json.JsonParseException: Invalid JSON input. Position: 9. Character: '.'.
我不知道为什么会收到 无效的 JSON 输入。位置:9. 字符:'.'.
当我执行GET
请求时?
我哪里错了?
最佳答案
缺少引号; @Query(value = "{'address.country':?0}")
——尼尔·伦恩
这对我也有用。
关于spring - JsonParseException : Invalid JSON input. 位置 : 9. 字符: '.',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50167424/