简体   繁体   English

如何从Java控制器中的Ext.Ajax.request获取参数

[英]How to get Parameter from Ext.Ajax.request in java controller

I am having one problem in retrieving the parameter which i am passing using Ext.Ajax.request to my JAVA controller class. 我在检索使用Ext.Ajax.request传递给我的JAVA控制器类的参数时遇到一个问题。

I am sending request to my controller using below code 我正在使用以下代码向我的控制器发送请求

Ext.Ajax.request({
             url : 'projecttask/GetprojectTasks.action',
             method: 'POST',
             jsonData: {
                sampledata: record.data
            },
            type: 'json',
            scope: this, // add the scope as the controller
             callback : function(options, success, response) {
                console.log('RESPONSE FROM SERVER :'+response);
             }
           });

my java controller method to receive the request is 我的接收请求的Java控制器方法是

@RequestMapping(value="/projecttask/GetprojectTasks.action")
    public @ResponseBody Map<String, ? extends Object> getprojectTasks(HttpServletRequest request,
            HttpServletResponse response,@RequestBody Project project) throws Exception {
        try {
            System.out.println("PROJECT ::"+project);
            System.out.println("RPOJECT DATA ::"+request.getParameter("sampledata"));
            Object data = request.getParameter("sampledata");
            Project prj = (Project) data;
            System.out.println("CREATE TASK DATA IS ::"+prj.getProjectid());            
            return null;            
        }catch(Exception e) {
            return getModelMapError("Error trying to create contact");
        }
    }

but it gives me error mentioned below 但这给了我下面提到的错误

org.codehaus.jackson.map.JsonMappingException: Unrecognized field "sampledata" (Class com.kintu.projectmgt.model.Project), not marked as ignorable

so what i am doing wrong which not allowed my function to get sampledata passed as parameters. 所以我做错了,这不允许我的函数获取作为参数传递的sampledata。 How can i get my Parameters passed value any idea ? 我怎样才能让我的参数传递值的任何想法?

My firebug shows that sampledata contains all values. 我的萤火虫显示sampledata包含所有值。 Please help me to find the problem and solve it as soon as possible. 请帮助我找到问题并尽快解决。

I am using Ext JS 4.0.2a and JAVA as my serverside technology. 我正在使用Ext JS 4.0.2a和JAVA作为我的服务器端技术。

you can use 您可以使用

String postParamsJSON = request.getReader().readLine();

to get the POST data. 获取POST数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Ext.Ajax.request将参数传递给servlet? - How to pass parameters to servlet using Ext.Ajax.request? 在Extjs差异中,黑白Ext.ajax.request和Ext.data.Connection - In Extjs Difference b/w Ext.ajax.request and Ext.data.Connection AJAX request sending null parameter to Java Spring controller - AJAX request sending null parameter to Java Spring controller 从Ext / Java应用程序中的JSONP请求获取响应文本 - Get response text from a JSONP request in Ext / Java Application 如何通过makePostRequest()中的Ajax调用发送文件并通过控制器中的request参数获取文件 - how to send file through ajax call in makePostRequest() and get it through request parameter in controller 如何从 Java 的请求中只获取一个字符串参数? - How to get only one String parameter from request in Java? 如何从Java请求中获取参数长HTML页面字符串? - How to get parameter long html page string from request in java? Spring Controller请求参数为来自jQuery get()的POJO - Spring Controller request parameter as POJO coming from jQuery get() 从Spring控制器获取对象列表到AJAX请求 - Get back an Object List from a Spring controller to a AJAX request 如何通过Wicket Ajax从Spring REST控制器发布请求并获取响应 - How to post a request and get response from Spring REST controller by Wicket ajax
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM