java - Unable to map request from jqgrid to Spring MVC Controller -
java - Unable to map request from jqgrid to Spring MVC Controller -
i trying send form info jqgrid spring mvc controller getting error http status 404-the requested resource not available.
.
below code. 1)overviewcontroller.java
@controller @requestmapping(value="overview") public class overviewcontroller { @autowired overviewservice service; @requestmapping(value="order.spring",method=requestmethod.get) public modelandview getorderview(modelmap map,httpsession session) { modelandview modelandview=new modelandview("vieworders"); modelandview.addobject("vieworders", new orderoverviewform()); homecoming modelandview; } @requestmapping(value="order.spring",method=requestmethod.post,produces="application/json") public @responsebody orderoverviewresponse getorderoverview(@requestparam("accid") integer accid ,@requestparam("fromdate")date fromdate ,@requestparam("todate")date todate ,@requestparam("transactiontype") string transactiontype ,@requestparam("_search") boolean search ,@requestparam(value="page", required=false) integer page ,@requestparam(value="rows", required=false) integer rows ,@requestparam(value="sidx", required=false) string sidx ,@requestparam(value="sord", required=false) string sord) { // system.out.println(form); orderoverviewform form=new orderoverviewform(fromdate, todate, accid, transactiontype); system.out.println("in overview post"); list<orderoverviewdata> datas=(list<orderoverviewdata>)service.getorderoverview(form, 1); (iterator iterator = datas.iterator(); iterator.hasnext();) { orderoverviewdata orderoverviewdata = (orderoverviewdata) iterator.next(); system.out.println(orderoverviewdata); } orderoverviewresponse response=new orderoverviewresponse(); response.setpage("1"); response.settotal("5"); response.setrows(datas); response.setrecords(string.valueof(datas.size())); homecoming response; } }
2) vieworders.jsp
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <script type="text/javascript" src="<c:url value="/resources/js/jquery-1.11.1.min.js"></c:url>"></script> <script type="text/javascript" src="<c:url value="/resources/js/jquery.jqgrid.min.js"></c:url>"></script> <script type="text/javascript" src="<c:url value="/resources/js/jquery-ui.min.js"></c:url>"></script> <link type="text/css" rel="stylesheet" href="<c:url value="/resources/css/jquery-ui.min.css"></c:url>" /> <link type="text/css" rel="stylesheet" href="<c:url value="/resources/css/ui.jqgrid.css"></c:url>" /> <script type="text/javascript"> $(function() { $("#target") .submit( function(event) { alert("h"); var data={}; data["accid"]= $('#accid').val(); data["fromdate"]= $('#fromdate').val(); data["todate"]= $('#todate').val(); data["transactiontype"]= $('#transactiontype').val(); $("#grid") .jqgrid( { url : '/online fund trading/overview/order.spring', datatype : 'json', ajaxgridoptions: { contenttype: 'application/json; charset=utf-8' }, mtype : 'post', colnames : [ 'customer id', 'account id', 'order id', 'order date', 'order amount', 'order units', 'order type', 'fund id' ], colmodel : [ { name : 'cusid', index : 'cusid', width : 15, editable : false, editoptions : { readonly : true, size : 10 }, hidden : true }, { name : 'accid', index : 'accid', width : 15, editable : true, editrules : { required : true }, editoptions : { size : 10 } }, { name : 'ordid', index : 'ordid', width : 15, editable : false, editrules : { required : true }, editoptions : { size : 10 } }, { name : 'orddate', index : 'orddate', width : 15, editable : false, editrules : { required : true }, editoptions : { size : 10 } }, { name : 'ordamount', index : 'ordamount', width : 15, editable : false, editrules : { required : true }, editoptions : { size : 10 } }, { name : 'ordunits', index : 'ordunits', width : 15, editable : false, editrules : { required : true }, editoptions : { size : 10 } }, { name : 'ordtype', index : 'ordtype', width : 15, editable : false, editrules : { required : true }, editoptions : { size : 10 } }, { name : 'fundid', index : 'fundid', width : 15, editable : false, editrules : { required : true }, editoptions : { size : 10 } } ], postdata : { accid : function() { homecoming $('#accid') .val(); }, fromdate : function() { homecoming $('#fromdate') .val(); }, todate : function() { homecoming $('#fromdate') .val(); }, transactiontype : function() { homecoming $('#fromdate') .val(); } }, rownum : 20, rowlist : [ 20, 40, 60 ], height : 200, autowidth : true, rownumbers : true, pager : '#pager', sortname : 'cusid', viewrecords : true, sortorder : "asc", caption : "orders overview", emptyrecords : "empty records", loadonce : false, loadcomplete : function() { }, jsonreader : { root : "rows", page : "page", total : "total", records : "records", repeatitems : false, cell : "cell", id : "id" } }); event.preventdefault(); }); }); </script> </head> <body> <form id="target" enctype="application/json"> <table> <tr> <td>enter accid</td> <td><input type="text" id="accid" /></td> </tr> <tr> <td>from date</td> <td><input type="text" id="fromdate" /></td> <td>to date</td> <td><input type="text" id="todate" /></td> </tr> <tr> <td>enter transaction type</td> <td><input type="text" id="transactiontype" /></td> </tr> <tr> <td colspan="4"><input type="submit" id="submit" value="get orders"></td> </tr> </table> </form> <div id="jqgrid"> <table id="grid"></table> <div id="pager"></div> </div> </body> </html> <br />
i have traced content of request , response in mozilla.
source accid=100&fromdate=&todate=&transactiontype=&_search=false&nd=1414507225627&rows=20&page=1&sidx=cusid&sord=asc
and request , response content,
response headersview source server apache-coyote/1.1 content-type text/html;charset=utf-8 content-length 1041 date tue, 28 oct 2014 14:40:25 gmt request headersview source host localhost:8080 user-agent mozilla/5.0 (windows; u; windows nt 6.1; en-us; rv:1.9.2) gecko/20100115 firefox/3.6 take application/json, text/javascript, */*; q=0.01 accept-language en-us,en;q=0.5 accept-encoding gzip,deflate accept-charset iso-8859-1,utf-8;q=0.7,*;q=0.7 keep-alive 115 connection keep-alive content-type application/json; charset=utf-8 x-requested-with xmlhttprequest referer http://localhost:8080/online_fund_trading/overview/order.spring content-length 110
i have addded jackson jars still not getting doing wrong. please help me in issue. thanks.
java jsp spring-mvc jqgrid
Comments
Post a Comment