Spring MVC -3 将服务器中数据体现在view ajax 重定向
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Spring MVC -3 将服务器中数据体现在view ajax 重定向,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3424字,纯文字阅读大概需要5分钟。
内容图文
将服务器返回值体现在view中
*
* desc:直接在参数的列表上定义PrintWriter,out.write(result);把结果写到页面,建议使用的
* author:任亮
* mail:renliangjava@163.com
* qq群:2636378537
* 班级:0922
*/
@RequestMapping("/ajax1.do")
public void ajax1(String name, PrintWriter out){
String result = "hello " +name;
out.write(result);
}
@RequestMapping("/toAjax.do")
public String toAjax(){
return "ajax";
}
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP ‘index.jsp‘ starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="js/jquery-1.6.2.js"></script>
<script type="text/javascript">
$(function(){
$("#mybutton").click(function(){
$.ajax({
url:"test/ajax1.do",
type:"post",
dataType:"text",
data:{
name:"zhangsan"
},
success:function(responseText){
alert(responseText);
},
error:function(){
alert("system error");
}
});
});
});
</script>
</head>
<body>
<input id="mybutton" type="button" value="click">
</body>
</html>
原文:http://www.cnblogs.com/hitxx/p/4849638.html
内容总结
以上是互联网集市为您收集整理的Spring MVC -3 将服务器中数据体现在view ajax 重定向全部内容,希望文章能够帮你解决Spring MVC -3 将服务器中数据体现在view ajax 重定向所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。