[英]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.