Spring controller - send html as response -


I have a jsp page loaded with products and add links against it. I am trying to show the cart in a div in the same page. I want to send html as feedback. This is what I have done. This is just the string & lt; Div & gt; Output & lt; / Div & gt; returns. Someone can show me how I should do it.

controller

  @RequestMapping (value = "/ addtocart {id}"), produces = "text / plain; charset = UTF -8 ") @ Risponsbodi public string Adtoart (@ Path variable (" ID ") Int ID, @ model attribute (" carriage ") train carts, models) {product product = Utpadsewa. ProductivityIID; If (product! = Null) {cartline line = new cartline (); Line.setProduct (product); Line.setQuantity (1); ProductService.updateProduct (product); } Return "
Output "; }

JSP

  & lt; Td> & Lt; An id = "demo4" href = "addtocart $ {product. Id}" & gt; Add to Cart & lt; / A & gt; & Lt; / TD & gt; Click $ ( '# Demo4') to (function () {$. Ajax ({url: '/ addtocart {id}', datatype 'Jason', content type "text / html", type: 'GET' Data: {Id: id}, success: function (response) {$ ('# output'). Html (response);}})}}; & Lt; Div id = "output" style = "display: none" & gt; & Lt; H2 & gt; Cart content (s): & lt; / H2 & gt; & Lt; / Div & gt;  

I use the scene as well as the side of a different page on the AJAX call I am However, whatever you are asking for, just to produce your production = "text / plain; described = UTF-8"

  output = "text There are many other aspects that appear to be incorrect, not related to Spring MVC, so even with the product You still have to make some corrections to get what you are expecting   

It will be something like this, if it works Not closer to more than, then it will not be completely

   

Rename

@RequestMapping (value = "/ addtocart {productId}", output = "text / plain; charset = UTF-8") Public String Adtart (@Path Variable ("Product ID") Ent Product ID, @ Model Attribute ("Cart") Cart Cart, Model Model)

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -