import org.apache.struts.action.ActionMapping;
public class UserAction extends Action {
private final static String SUCCESS = "success";
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm userForm = (UserForm) form;
ForbesData actorData = new ForbesData();
userForm.setForbesList(actorData.loadData());
return mapping.findForward(SUCCESS);
}
}
第3步:创建JSP,struts-config.xml和web.xml文件
在WebContent文件夹和struts-config.xml和web.xml中的WebContent / WEB-INF文件夹中创建index.jsp和user.jsp。

复制以下内容转换成相应的文件。
index.jsp的
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
//原文由 www.software8.co 站长百科译
<jsp:forward page="userAction.do"/>
user.jsp
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://displaytag.sf.net" prefix="display" %>
The World's Billionaires 2009 - Forbes List
requestURI="/userAction.do" pagesize="10" >
struts-config.xml中
< xml version="1.0" encoding="UTF-8" >
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
web.xml中
< xml version="1.0" encoding="UTF-8" >
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
org.apache.struts.action.ActionServlet
第4步:执行项目
我们已经完成了这个项目。现在执行的项目在Eclipse中创建一个WAR文件,并在Tomcat上运行。
