简体   繁体   中英

Can I exclude field from post and put requests but expose it in get in spring-data-rest?

I have a model where I have something like this

public class Foo {

private int foo;
private int bar;

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

So I'd like user to be able to see bar, but not directly affecting it. Is that achievable?

I think what you need is a getter for bar .

public int getBar() {
   return bar;
}

So it is visible but not changeable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM