struts不执行action 写个简单的STRUTS用户登录,在FORM中可以返回输入错误,但是想验证输入名字时ACTION中就没有反应了,哪位高手帮帮忙。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的toString()方法重写了没! 如何把formbean中的信息,在action中打印出来并显示? 你那就在action中写一个打印语句看看打印什么东西没有,确定是否进入了action如果进入了就表示要么没有找到转发的页面,要么就是在这个页面上写错了...测试办法,在action中加入打印语句,在页面只写一句话,不显示任何其它内容,如果看到这句话就表示页面有问题 我只写了一句System.out.print("goodnews");return null;但是没有打印出结果; 如何把formbean中的信息,在action中打印出来并显示?==============================System.out.print(xxxForm.getUser()); 恩,在调试action里打印语句,一步一步跟。 package cn.com.wang;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.sql.*;import cn.com.wang.DbConnect;import cn.com.wang.LoginForm;import javax.servlet.http.HttpSession;import org.apache.struts.action.ActionForward;import org.apache.struts.action.Action;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;public final class LoginAction extends Action { public ActionForward execute(ActionMapping mapping,HttpServletRequest request,HttpServletResponse response,ActionForm form)throws Exception{ //ActionErrors errors=new ActionErrors(); //HttpSession s=request.getSession(); //String s_user=null; //LoginForm loginForm1=(LoginForm)form; //String niceName=loginForm1.getNiceName(); //String passWord=loginForm1.getPassWord(); //String niceName=request.getParameter("niceName"); //System.out.print("niceName"); System.out.print("goodnews"); return null; //return mapping.findForward("logerror"); //System.out.print("s"); // if(niceName==null){ // return (new ActionForward(mapping.getInput())); // } //DbConnect db=DbConnect.getInstance(); //if(db!=null){ /* errors.add("fail_1",new ActionError("log.action.a")); saveErrors(request,errors); return (mapping.findForward("login")); } ResultSet st=null; String sql="select * from web_user where niceName='"+niceName+"'and passWord='"+passWord+"'"; st=db.read(sql); System.out.println(sql); if(st!=null && st.next()){ s_user=(String)s.getAttribute("current_user"); if(s_user==null){ s.setAttribute("current_user", niceName); return (mapping.findForward("login")); }else{ s.removeAttribute("current_user"); s.setAttribute("current_user",niceName); return (mapping.findForward("login")); } }else{ errors.add("fail_2", new ActionError("log.error.c")); saveErrors(request,errors); return (mapping.findForward("logerror")); }*/ } }这样了还是打印不出东西 s_user=(String)s.getAttribute("current_user");有什么用? //LoginForm loginForm1=(LoginForm)form;你有配置表单bean吗? 在Google app engine里面怎么绘图,产生验证码 求教c3p0的问题。 急求 class文件打成jar后,放到lib下不能被找到 Hibernate3 删除数据问题 jsp如何实现数据库的备份,还原 关于输入输出方法的一个小问题 很奇怪的问题 jsp WEB服务器问题 高手过来看一下 网站程序中的ArrayList问题 Jpf.NavigateTo.currentPage问题
System.out.print("goodnews");
return null;
但是没有打印出结果;
==============================
System.out.print(xxxForm.getUser());
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import cn.com.wang.DbConnect;
import cn.com.wang.LoginForm;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public final class LoginAction extends Action {
public ActionForward execute(ActionMapping mapping,HttpServletRequest request,HttpServletResponse response,ActionForm form)throws Exception{
//ActionErrors errors=new ActionErrors();
//HttpSession s=request.getSession();
//String s_user=null;
//LoginForm loginForm1=(LoginForm)form;
//String niceName=loginForm1.getNiceName();
//String passWord=loginForm1.getPassWord();
//String niceName=request.getParameter("niceName");
//System.out.print("niceName");
System.out.print("goodnews");
return null;
//return mapping.findForward("logerror");
//System.out.print("s");
// if(niceName==null){
// return (new ActionForward(mapping.getInput()));
// }
//DbConnect db=DbConnect.getInstance();
//if(db!=null){
/* errors.add("fail_1",new ActionError("log.action.a"));
saveErrors(request,errors);
return (mapping.findForward("login"));
}
ResultSet st=null;
String sql="select * from web_user where niceName='"+niceName+"'and passWord='"+passWord+"'";
st=db.read(sql);
System.out.println(sql);
if(st!=null && st.next()){
s_user=(String)s.getAttribute("current_user");
if(s_user==null){
s.setAttribute("current_user", niceName);
return (mapping.findForward("login"));
}else{
s.removeAttribute("current_user");
s.setAttribute("current_user",niceName);
return (mapping.findForward("login"));
}
}else{
errors.add("fail_2", new ActionError("log.error.c"));
saveErrors(request,errors);
return (mapping.findForward("logerror"));
}*/
}
}
这样了还是打印不出东西
s_user=(String)s.getAttribute("current_user");有什么用?
你有配置表单bean吗?