日期:2014-05-16 浏览次数:20286 次
<script type="text/javascript" src="<%=path%>/js/jquery.js"></script> <script type="text/javascript"> $(function(){ $.getJSON("login.action",{},function(result){ var r = eval(result);//将json字符串转为js对象 alert(r.name); }); }); </script>
<package name="default" namespace="/" extends="json-default"> <action name="login" class="com.liyh.struts.web.HelloJsonAction" method="login"> <result type="json"></result> </action> </package>
public class HelloJsonAction extends ActionSupport { private String name;//省略getter和setter @JSON public String login() { this.name = "dd"; return SUCCESS; } }