How to send object as attribute of another object from a JSP to a Spring controller?

0

Hello, I have a News related ManyToOne class with a Section class. The News class has an attribute of type Section (where the @ManyToOne relation occurs). I would like to know how I can, in the newsprint form, send the section to which it should be part.

Note: I already have the list of available sections in the JSP and the user selects the section for the news that will register through a selection field. But I do not know how to pass the dry object as attribute of the news that will be registered. Can anyone help me?

Thank you.

    
asked by anonymous 02.07.2016 / 03:27

1 answer

0
<select name="secao.atributoDeSecaoQueSeraDefinido">
  <option value="politica">Política</option>
</select>

You can try to do this, but since you should already have the registered section, I think getting the ready object of the form will not make the relationship. Then you just get the value of the section that the guy chose, search for the object of this section and define in the news object.

    
07.07.2016 / 14:20