如何从java控制器中的Ext.Ajax.request获取参数
我在检索使用 Ext.Ajax.request 传递给 JAVA 控制器类的参数时遇到一个问题。
我使用下面的代码向我的控制器发送请求,
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);
}
});
我的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");
}
}
但它给了我下面提到的错误
org.codehaus.jackson.map.JsonMappingException: Unrecognized field "sampledata" (Class com.kintu.projectmgt.model.Project), not marked as ignorable
,所以我做错了什么,不允许我的函数获取作为参数传递的样本数据。我怎样才能得到我的参数传递值任何想法?
我的萤火虫显示样本数据包含所有值。请帮我尽快找到问题并解决。
我使用 Ext JS 4.0.2a 和 JAVA 作为我的服务器端技术。
I am having one problem in retrieving the parameter which i am passing using Ext.Ajax.request to my JAVA controller class.
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
@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. How can i get my Parameters passed value any idea ?
My firebug shows that sampledata contains all values. 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用它
来获取 POST 数据。
you can use
to get the POST data.