当前位置: 代码迷 >> Java Web开发 >> 请教高手,为什么struts2中的action为什么不能执行System.out.println()
  详细解决方案

请教高手,为什么struts2中的action为什么不能执行System.out.println()

热度:4242   发布时间:2013-02-25 21:21:04.0
请问高手,为什么struts2中的action为什么不能执行System.out.println()
action中的代码如下:
public String loginCheck() {
System.out.println("action doing...");
ActionContext ctx = ActionContext.getContext();
String str[] = (String[]) ctx.getParameters().get("hiddenfield1");
if(getUsername().equals("wa")){
return SUCCESS;
}else{
return ERROR;
}
}
页面访问action时,后台为什么不能执行System.out.println("action doing...")这句话。

------解决方案--------------------------------------------------------
打断点看看啊,你是不是用其他框架了?有些东西把它给封装了。。。蛋不是struts2
------解决方案--------------------------------------------------------
没有进到loginCheck方法
------解决方案--------------------------------------------------------
你看下你的struts配置和页面指向的action 地址是否正确?如果进来了,那句不可能不打印
------解决方案--------------------------------------------------------
楼上说的都对,只要进入到方法中System.out.println()是肯定会执行的,没执行的原因肯定是没进入到action中对应的方法,可能是struts.xml中配置错了,也可能是跳转的时是不是代码敲错了。建议楼主检查下。
  相关解决方案