Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring mvc multipart
    primarykey
    data
    text
    <p>I keep getting the following error </p> <blockquote> <p>org.springframework.web.multipart.support.MissingServletRequestPartException: Request part 'model' not found.</p> </blockquote> <p>When posting multipart request to spring mvc controller.</p> <p>This is the request:</p> <pre><code>Accept:application/json, text/javascript, */*; q=0.01 Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8 Connection:keep-alive Content-Length:4394941 Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryK4y8t7mg2SNoYxC4 Cookie:SID=091f182f-5534-47c4-b0c1-8ca9c17e1f09 Host:localhost:8080 Origin:http://localhost:8080 Referer:http://localhost:8080/controller/home/ User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17 X-Requested-With:XMLHttpRequest Request Payload ------WebKitFormBoundaryK4y8t7mg2SNoYxC4 Content-Disposition: form-data; name="model" {"name":"kjkjk","description":"kkjkjk"} ------WebKitFormBoundaryK4y8t7mg2SNoYxC4 Content-Disposition: form-data; name="photo"; filename="IMG_1281.JPG" Content-Type: image/jpeg </code></pre> <p><strong>Controller</strong></p> <pre><code>@RequestMapping(value = "/t") public ResponseEntity&lt;ResponseMessage&gt; t(@CookieValue(value = "SID", required = true) String sessionId, @RequestPart("model") CategoryModel model, @RequestPart("photo") MultipartFile file) { return new ResponseEntity&lt;ResponseMessage&gt;(new ResponseMessage(200, "success"), HttpStatus.OK); } </code></pre> <p><strong>Model</strong></p> <pre><code>package bla.bla.bla; import java.util.ArrayList; import java.util.List; import java.util.Vector; import org.codehaus.jackson.annotate.JsonBackReference; import org.codehaus.jackson.annotate.JsonIgnore; public class CategoryModel { public CategoryModel(String id, String name, String description, CategoryModel parent) { super(); this.name = name; this.description = description; this.id = id; this.parent = parent; } public CategoryModel(String id, String name, String description, CategoryModel parent, List&lt;CategoryModel&gt; childrens) { super(); this.name = name; this.description = description; this.id = id; this.parent = parent; this.childrens = childrens; } public CategoryModel() { } public String id; public String name; public String description; public String imageUrl; public CategoryModel parent; public List&lt;CategoryModel&gt; childrens = new ArrayList&lt;CategoryModel&gt;(); } </code></pre> <p>I have added controller and entity please do check and let me know where am I going wrong?</p> <p>Thank you, James</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload