六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 102|回复: 0

哥真的很纠结,该死的<s:debug></s:debug>

[复制链接]

升级  40%

4

主题

4

主题

4

主题

童生

Rank: 1

积分
20
 楼主| 发表于 2013-2-7 19:49:34 | 显示全部楼层 |阅读模式
遇到这样的问题,要有多郁闷就有多郁闷,要有多纠结就有多纠结。在此陈诉,省的大家也犯同样的错。
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也在条用东西。下班了.....
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表