web
<?xml version=
<web
xmlns=
xmlns:xsi=
xsi:schemaLocation=
/xml/ns/javaee/web
<filter>
<filter
<filter
</filter>
<filter
<filter
<url
</filter
</web
struts
<?xml version=
<!DOCTYPE struts PUBLIC
<struts>
<package name=
<action name=
<result name=
<result name=
<result name=
</action>
</package>
</struts>
LoginAction
package HelloWorld;
import com
import com
import com
public class LoginAction extends ActionSupport…{
private String username;
private String password;
private String[] books;
public String[] getBooks() …{
return books;
}
public void setBooks(String[] books) …{
this
}
public String execute() throws Exception…{
if(this
ActionContext
BookService bs=new BookService()
this
return SUCCESS;
}else…{
return ERROR;
}
}
public String getUsername() …{
return username;
}
public void setUsername(String username) …{
this
}
public String getPassword() …{
return password;
}
public void setPassword(String password) …{
this
}
}
BookService
package HelloWorld;
public class BookService …{
private String[] books=new String[]…{
};
public String[] getBooks()…{
return books;
}
}
LoginAction
<?xml version=
<!DOCTYPE validators PUBLIC
<validators>
<field name=
<field
<message key=
</field
</field>
<field name=
<field
<message key=
</field
</field>
</validators> login
<%…@ page language=
pageEncoding=
<%…@ taglib prefix=
<html>
<head>
<title></title>
</head>
<body>
<s:form action=
<s:textfield name=
<s:password name=
<s:submit value=
</s:form>
</body>
</html>
welcome
<%…@ page language=
pageEncoding=
<%…@ page isELIgnored=
<%…@ taglib prefix=
<%…@ taglib prefix=
<html>
<head>
<title></title>
</head>
<body>
歡迎${sessionScope
<c:out value=
<br>
<table border=
<s:iterator value=
<s:if test=
<tr style=
</s:if>
<s:else>
<tr>
</s:else>
<td>書名
<td><s:property/></td>
</tr>
</s:iterator>
</table>
</body>
</html>
error
<%…@ page language=
pageEncoding=
<html>
<head>
<title></title>
</head>
<body>
登陸失敗
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28814.html