2 wh43023 wh43023 于 2014.12.05 15:28 提问

javaweb验证码黑色部分出错,为什么了?

package action;

import model.Manager;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import dao.ManagerDAO;

public class LoginAction extends ActionSupport
{
private String rand; //表单中的rand

public String getRand() {
return rand;
}
public void setRand(String rand) {
this.rand = rand;
}

Manager manager = new Manager();
public Manager getManager()
{
    return manager;
}
public void setManager(Manager manager)
{
    this.manager=manager;
}
@Override
public String execute() throws Exception
{
    ManagerDAO managerDAO = new ManagerDAO();

    if (managerDAO.isCheck(this.manager.getUsername(), this.manager.getPassword()))
    {
        Manager manager = new Manager();

        manager.setUsername(manager.getUsername());
        manager.setPassword(manager.getPassword());

        ActionContext.getContext().getSession().put("userInfo", manager);

        return SUCCESS;
    }
    return INPUT;
}

//从session中取出RandomAction.java 中生成的验证码random
String arandom=(String)(ActionContext.getContext().getSession().get("random"));{

//下面就是将session中保存验证码字符串与客户输入的验证码字符串对比了
if(arandom.equals(this.getRand()))
{
     ActionContext.getContext().getSession().put("random", this.getUsername());

return SUCCESS;

}
else {

return ERROR;

}

}

private Object getUsername()
{
    // TODO Auto-generated method stub
    return null;
}

}

1个回答

xmt1139057136
xmt1139057136   Rxr 2015.01.14 12:57

网上有源码的,多搜索搜索,答案就出来了。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!