//--------------------------jsp-------------------------------------//
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ jquery 包 "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<script type="text/javascript">
function dispDiv(){
$.ajax({
type : "POST", //提交的方式
url : '\executeLogin.action', //提交的action 地址
//data :"threadId="+1+"&clubId="+2+"&index="+3, //这里是要传的action的 需要的参数 没有可以不需要
dataType : "test",
success : function(msg) {
alert("ajax返回成功");
alert("成功的数据"+msg);
},error: function(){
alert("ajax 返回错误了");
}
});
}
</script>
<head>
<title>login</title>
</head>
<%@include file="/common/header.jsp" %>
<input type="button" value="sss" οnclick="dispDiv();">
</html>
//--------------------------------action mother-------------------------------//
public String execute(){
System.out.println("code"+Constants.VALIDATE_CODE_KEY);
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/plain;charset=utf-8");
try {
response.getWriter().write("{result: '你好!(这消息来自服务器)'}");
response.getWriter().flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "index";
}