Spring MVC 2.x 与 ajax 使用 jquery 等。
I have a scenario of ajax call to spring mvc controller to get the text.
请提供一个例子。 我必须使用 Spring 2.x 而不是 spring 3.x。
like:
Model m=new HashMap();
m.put("textToAjax","Sample");
return new ModelAndView("",m);
And i need to get this text, ie Sample on my jsp text box.
Tha ajax call is like
$.ajax({
type:"GET",
url:"test.hmtl?method=getTextName",
.............
});
Please correct this and help me with full example.enter code here
I have a scenario of ajax call to spring mvc controller to get the text.
Please provide an example of this.
I have to use Spring 2.x not spring 3.x.
like:
Model m=new HashMap();
m.put("textToAjax","Sample");
return new ModelAndView("",m);
And i need to get this text, ie Sample on my jsp text box.
Tha ajax call is like
$.ajax({
type:"GET",
url:"test.hmtl?method=getTextName",
.............
});
Please correct this and help me with full example.enter code here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我目前的做法和工作原理:
将 test.html 映射到 TestController:
在dispatcher-servlet.xml 中声明 TestController:
创建一个简单的视图文件“result.jsp”用于显示 ajax 响应:
映射此视图:
开发 TestController :
现在,在您的 html 文件中,您可以像这样调用 TestController:
在本例中,每次单击“获取时间”按钮时都会显示时间。
此致
here's how I currently do and it works:
Map the test.html to a TestController:
Declare TestController in the dispatcher-servlet.xml:
Create a simple view file "result.jsp" for displaying ajax response:
Map this view:
Develop the TestController:
Now, in your html file, you can call the TestController like this:
In this example, the time will be displayed each time you click on the "Get time" button.
Best regards