|
遇到这样的问题,要有多郁闷就有多郁闷,要有多纠结就有多纠结。在此陈诉,省的大家也犯同样的错。
public class MoveAction extends ActionSupport {//public List<GoWays> list;private GoWays goWays;public String addUser(){//list = new ArrayList<GoWays>(1);System.out.println(goWays.getName());System.out.println(goWays.getWay());//list.add(goWays);return SUCCESS;}public String getIsss(){System.out.println("---------------------");return SUCCESS;}public String getInfo(){System.out.println("%%%%%%%%%%%%%%%%%%%%%%"); HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("text/html;charset=UTF-8"); //设置返回值的编码 PrintWriter out; try { out = response.getWriter(); //out.print(name + date); out.print("{'name':'a','age':2},{'name':'b','age':2}"); out.close(); } catch (IOException e) { e.printStackTrace(); } return SUCCESS;}public GoWays getGoWays() {return goWays;}public void setGoWays(GoWays goWays) {this.goWays = goWays;}}
大家可以看到这样的action。好,我现在用xml文件访问,代码如下:
<struts><constant name="struts.devMode" value="true" /><constant name="struts.i18n.encoding" value="utf-8"></constant><constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant> <package name="game" namespace="/" extends="struts-default" > <action name="adduser" class="com.sun.game.action.MoveAction"> <result>/index.jsp</result> </action> </package></struts>
浏览器输入:http://localhost:8080/Test/addUser.jsp
好!开始跳转.....咦,怎么出现这样的内容:
{'name':'a','age':2},{'name':'b','age':2}
更奇怪的是后台居然是这样的输出:
sun
222
%%%%%%%%%%%%%%%%%%%%%%
---------------------
...这个不是每个类似execute的那个方法都执行了一次吗?可是俺只条用了addUser啊。
晕,没时间了,下班了,不细细讲了。问题出在index.jsp页面中我放了这样的标签<s:debug></s:debug>导致出的问题,这个debug也在条用东西。下班了..... |
|