Note that there are some explanatory texts on larger screens.

plurals
  1. PO400 Bad request on Spring Jquery Ajax Post
    primarykey
    data
    text
    <p>I'm getting a 400 bad request on this POST request. Any idea what the issue is here ? Logs are <a href="http://db.tt/0Dtl7PWu" rel="noreferrer">here</a>.</p> <p>Controller</p> <pre><code>@Controller public class AjaxController { @RequestMapping(value="/addKeys", method=RequestMethod.POST, consumes="application/json; charset=UTF-8") public ResponseEntity&lt;String&gt; addKeys(@RequestParam(value="keys") ArrayList&lt;Keys&gt; keys){ System.out.println("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"+keys); } } </code></pre> <p>context-Servlet.xml</p> <pre><code>&lt;beans&gt; &lt;mvc:annotation-driven /&gt; &lt;context:component-scan base-package="com.canon.fw.controller" /&gt; &lt;bean id="defaultViews" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /&gt; &lt;/beans&gt; </code></pre> <p>Ajax</p> <pre><code>tmpList = '[{"key":"camera","label":"Camera"},{"key":"mobile","label":"Mobile"}]'; $.ajax({ type: 'POST', url: ctx+'/ajx/addKeys', data: JSON.stringify({"keys": tmpList }), success: function(r){ if(r.model.status=='success'){ debugger; //glist.push(elem.key); //addToList(elem.key, elem.label); highlightInfoDisc(); } }, dataType: 'json', contentType: 'application/json' }); </code></pre> <p>FireBug - URL</p> <pre><code>http://localhost:8080/Di/ajx/addKeys </code></pre> <p>Firebug - Response Headers</p> <pre><code>Cache-Control must-revalidate,no-cache,no-store Content-Length 1384 Content-Type text/html; charset=iso-8859-1 Server Jetty(6.1.26) </code></pre> <p>Firebug - Request Headers</p> <pre><code>Accept application/json, text/javascript, */*; q=0.01 Accept-Encoding gzip, deflate Accept-Language en-us,en;q=0.5 Connection keep-alive Content-Length 74 Content-Type application/json; charset=UTF-8 Cookie JSESSIONID=7mymobst47ig1s7uqy2z1fvx4 Host localhost:8080 Referer http://localhost:8080/Di/tiles/entNews.htm User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1 X-Requested-With XMLHttpRequest </code></pre> <p>Firebug - Source</p> <pre><code>{"keys":[{"key":"canon","label":"Canon"},{"key":"ricoh","label":"Ricoh"}]} </code></pre> <p>Firebug - Response</p> <pre><code>"NetworkError: 400 Bad Request - http://localhost:8080/Di/ajx/addKeys" </code></pre>
    singulars
    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.
 

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