forms - The foreach tag in JSP and how to write the code in the Java controller -


I have a controller (registered controller. Java) and I want the controller to output JSP (its name is commment_form.jsp is). So I use every tag in jsp to display a list of comments (comments about a given resource that the user has been given). I usually mean an image for "processing". So there is a list of comments about "image" and I want all the comments to be displayed in all the pages below, when a comment commentary will be put in the form. My question is how should the code be written in the controller so that output can be set for JSP? Should I use a @model attribute, a put-attribute or something? Here is the code of the controller and jsp:

comment_arm.asp:

   & Lt; C: Out value = "$ {comments.content}" & gt; & Lt; / C: Out & gt; & Lt; / Td> & Lt; Td> & Lt; C: out value = "$ {comments.content}     & lt; & lt; ; / Form: form>  

Registered Controller is Java:

  @RequestMapping ("/ comment.do") public string comment (@ Module specialty comment comment, binding result binding model, model model, locale locale) {user user = user service.gateusir content (); commented .set publications (SQLUtility.getCurrentDate ()); comment.setIdUser (user.getId ()) ; CommentService: Create (comment); [] Arguments = {comment .getId ()}; string message = messageSource.getMessage ("message.update", args, locale); list & lt; comment & gt; comments = commentService.findAllCommentByResource (comment.getIdResource () Model.addAttribute ("comments", comments Model.addAttribute ("id", comment.getIdResource ()); model.addAttribute ("message", message); model.addAttribute ("comment", comment); Return "Redirect: / regis tered / comment_start.do"; }  

Any help please? I will appreciate . Thank you.

Redirection Properties

in the case of additional data in the redirect pass

To redirect data in a redirect use.

Does Java Doc say:

The model of a redirect properties is empty when the method is called and never until the redirect view returns the name or redirect view. Until then it is used.

After the redirect, Flash attributes are automatically added to the controller's model which serves the target URL.


An additional note:

Instead of $ {comment.content} in JSP should be $ {comments}. Content}


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -