STRUTS2.0例子中的简单登录

STRUTS2.0例子中的简单登录

LoginAction:

 


package org.rainlife.struts2.action;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {
    private String username;

    private String password;

    @Override
    public String execute() throws Exception {
        if (!(getUsername().equals("rainlife"))
                && !(getPassword().equals("rainlife"))) {
            return ERROR;
        } else {
            return SUCCESS;
        }
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

}

struts2.0例子里面的一个ACTION
编译怎么通不过?

LoginAction.java:3: package com.opensymphony.xwork2 does not exist
import com.opensymphony.xwork2.ActionSupport;

异常提示找不到包;

所以要设定路径:

是放在桌面上的;

这样设定路径:

C:\>set classpath=C:\Documents and Settings\chenchuxin\桌面\新建文件夹 (3)\2011
200966\Struts2_Login\WEB-INF\lib\struts.jar;

C:\Documents and Settings\chenchuxi
\桌面\新建文件夹 (3)\20114200966\Struts2_Login\WEB-INF\lib\xwork-2.0-beta-1.jar
%classpath%

 

再编译就通过了;



你可能感兴趣的:(eclipse,C++,c,struts,JBuilder)