我可以从post和put请求中排除字段,但是在spring-data-rest中将它暴露出来吗?

时间:2015-07-31 10:20:48

标签: java spring spring-data-rest

我有一个模型,我有这样的东西

public class Foo {

private int foo;
private int bar;

public setFoo(int foo) {
   bar = someFunction(foo);
}
}

所以我希望用户能够看到酒吧,但不会直接影响它。这是可以实现的吗?

1 个答案:

答案 0 :(得分:0)

我认为你需要的是bar的吸气剂。

public int getBar() {
   return bar;
}

所以它是可见的,但不可更改。