search

Home  >  Q&A  >  body text

java - spring mvc receives an object. How to set different properties of the object?

@RequestMapping(value = "/listByUserId")
public PageInfo<Product> listByUserId(User user) {
    
}

What I am receiving is a User object, in which the User attribute id, I want to set an initial value for it, that is, there is an initial value when the id parameter is not sent. I use @RequestParam to specify the id attribute defalutValue, but it does not work. Is there any way to achieve this? It is best not to change to the User class

漂亮男人漂亮男人2764 days ago842

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-05-27 17:42:38

    This is what I wrote:

    @RequestMapping(value="/student/{st_no}",method= RequestMethod.GET)
    public Student info(@PathVariable Integer st_no){
    }

    reply
    0
  • Cancelreply