【发布时间】:2016-02-17 02:25:28
【问题描述】:
我目前正在使用 JHipster v2.23。我必须自定义 User 类来添加一些属性。一切都很好,直到我不得不为其添加一对多的关系。
public class User extends AbstractAuditingEntity implements Serializable {
// attributes...
private Set<MyClass> myClass = new HashSet<>();
// gets/sets
}
从视图方面,我对注册表进行了必要的更新,包括处理 1 对 n 关系所需的代码。但是,当我尝试将其发布到 /api/register 时,出现以下错误(只需在 register.controller.js 中设置 $scope.registerAccount.myClass=[] 即可重现它,因为将发送此数组在注册表格发布时的json中):
"The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers."
我已经阅读了一些关于这个问题的帖子:
- Spring MVC + JSON = 406 Not Acceptable
- spring mvc not returning json content - error 406
- Spring 3.x JSON status 406 "characteristics not acceptable according to the request "accept" headers ()"
我尝试了几种方法:
- 添加了@EnableWebMvc,但我开始看到一些映射错误;
- 添加一些 jackson 依赖项,但没有帮助;
我想知道 JHipster 代码是否真的没有准备好处理这种情况,因为它似乎并不罕见。
以前有人遇到过这个问题吗? 有关如何使用 JHipster 解决此问题的任何提示?
提前致谢。
【问题讨论】:
标签: jhipster