dn'我找不到适合课堂的语法元素
dn't find a grammar element for class
我有一个jersey服务,正在尝试使用xmlhttprequest 调用它
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public SomeJsonClass myService(SomeClassName classObject) throws RuntimeException, IOException,
InterruptedException {
//Some code to handle request
return jsonClassObject;
}
我试着用以下方式来称呼它:
<!DOCTYPE html>
<html>
<head>
<title>jQuery</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<p>Click the button to demonstrate the prompt box.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction()
{
var json=prompt("Enter JSON");
alert("JSON: "+json);
var xhr = new XMLHttpRequest();
xhr.open("post","http://localhost:8080/otp/rest/validate-otp");
xhr.setRequestHeader("Content-Type","application/json;charset=UTF-8");
xhr.responseType = "json";
xhr.send(JSON.stringify(json));
}
</script>
</body>
</html>
当我尝试运行此代码时,收到"找不到类的语法元素"警告。当我尝试使用rest客户端发送相同的json时,服务会给出正确的响应。
这里可能有什么问题?
看看本文是否使用JAX-RS和Jersey使用jQuery和Java提供RESTful服务http://coenraets.org/blog/2011/12/restful-services-with-jquery-and-java-using-jax-rs-and-jersey/对你有帮助。
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- jQuery语法添加了var
- Javascript未捕获语法错误意外的标识符错误
- 为什么忽略了eval()代码中的语法错误
- 难以访问的JS环境中的语法错误
- 如何告诉MathJax对下标使用替代语法
- Javascript语法向设置发出sessionStorage值
- 未捕获的语法错误:意外的标记{
- 使用$scope方法时的ControllerAs语法
- "未捕获的语法错误:意外的标记}"
- javascript自执行函数-不同的语法
- 函数的Javascript语法
- WinJS内联绑定语法
- 使用JS函数来使用另一个函数的语法?node.js
- 未捕获的语法错误:无法在“文档”上执行“查询选择器”
- 有没有针对带有表的JavaScript的Markdown语法解析器
- 在递归生成器函数中,yield后面的*(星号/星号)语法意味着什么
- React JS:未捕获(在承诺中)语法错误:在位置 0 的 JSON 中意外<令牌
- 当使用控制器作为语法时,如何从父指令继承属性
- dn'我找不到适合课堂的语法元素