我有一个 Spring MVC 3/J2EE 项目。jsp 呈现控制器工作正常,但为 Ajax 呈现 XML 的一个控制器无法正常工作。我在 RAD 7.5 中使用 JDK 1.6,所以 JAXB 应该在类路径上,我什至尝试将最新的 JAXB jar 添加到 lib 文件中以确保。 当我拨打电话时,我仍然收到 406 错误。 我的 DOJO 电话有handleAs: "xml"
,我已经通过 FireBug 确认它application/xml
在Accept
标题上。我的 spring servlet xml 文件中有这一<mvc:annotation-driven />
行。我可以看到该方法被调用并返回而没有错误。我不确定接下来应该尝试什么来调试。
//Country is a class with only primative types which implements Serializable.
public @ResponseBody List<Country> getCountries(){
return addressService.getCountries();
}
function loadData(){
console.log("Before get ...");
dojo.xhrGet({
url:"http://localhost:9080/sample/shared/getCountries.htm",
handleAs:"xml",
load: function(data){
console.log("In load function ...");
try {
for(var i in data){
console.log("key", i, "value", data[i]);
}
}catch (ex){
console.error("Failure in load function: " + ex);
}
console.log("Exiting load function ...");
},
error: function(x){
console.error("Error in ajax ...");
console.error(x);
},
failOk: false
});
console.log("After get ...");
}