日期:2014-05-17  浏览次数:20838 次

struts2.0 问题,初学简单例子运行出错


//-------------------
loginAction.java


package com.action;

import com.opensymphony.xwork2.ActionSupport;

public class loginAction extends ActionSupport{
private String username;   
    private String password;  
    
    public String getUsername() {   
        return username;   
    }   
    public void setUsername(String username) {   
        this.username = username;   
    }   
    public String getPassword() {   
        return password;   
    }   
    public void setPassword(String password) {   
        this.password = password;   
    }   

    public String execute(){   
        return SUCCESS;          
    }  
}

//--------------------
login.jsp


<%@ page language="java" contentType="text/html" pageEncoding="GBK"%>   
<%@ taglib prefix="s" uri="/struts-tags"%> 
<html>   
<head>     
<title>Insert title here</title>   
</head>   
<body>   
<s:form action="login">   
    <s:textfield name="username" label="username"></s:textfield>   
    <s:password name="password" label="password"></s:password>   
    <s:submit label="submit"></s:submit>   
</s:form> 
</body>   
</html>  
//--------------------------------------
result.jsp

<%@ page language="java" contentType="text/html" pageEncoding="GBK"%>   
<%@ taglib prefix="s" uri="/struts-tags"%> 
<html>   
<head>   
<title>Insert title here</title>   
</head>   
<body>   
    username:${requestScope.username}
    <br>    
    password:${requestScope.password}    
</body>   
</html>  
//---------------------------------
struts.xml


<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="struts2" extends="struts-default">  &nbs