1.找到strtus1.1 中的这个文件(struts-example.war)将它解包。(要用到里面的很多文件)
2.在jb下安装struts1.1(jb9里的配置方法,可以参考一下)
Struts1.1比Struts1.0功能增强了很多。比如:提供DynaActionForms,可不用编写任何代码创建动态的ActionForm;多应用支持答应定义多个struts-config.XML配置文件等等。但JBuilder 9只直接支持Struts1.0,不直接支持Struts1.1,下面让我们来看看怎样让JBuilder 9支持Struts1.1。
首先下载 jakarta-struts-1.1,把整个目录放到/extras目录下.
接着在JBuilder用 Configure Libraries对话框 (Tools--Configure Libraries)创建一个新的library ,我们命名为Struts1.1,把jakarta-struts-1.1lib目录下所有的jar添加到新的library里,在library Settings里设置Framework为Struts,点OK,设置完成.
接下来看看设置是否成功:
File--New创建一个web application, 在Web Application wizard的jsp/Servlet frameworks中我们看到了Struts 1.1选择框,设置成功!
接下来您就可以在JBuilder9里使用Struts1.1开发您的Web Application了.
3.配置struts-config.xml文件 (文件如下:)
<?xml version="1.0" encoding="UTF-8"?
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";
<struts-config
<form-beans
<form-bean name="testForm" type="test.testForm" /
</form-beans
<action-mappings
<action name="testForm" type="test.testAction" validate="true" scope="request" path="/testAction"
<forward name="test" path="/test.jsp" /
</action
</action-mappings
<message-resources parameter="test.ApplicationResources" /
<plug-in className="org.apache.struts.validator.ValidatorPlugIn"
<set-property value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" property="pathnames" /
</plug-in
</struts-config
3.建立 testForm.Java 继续ValidateForm
package test;
import org.apache.struts.validator.*;
import org.apache.struts.action.*;
import javax.servlet.http.*;
public class testForm extends ValidatorForm {
private String testText;
public void setTestText(String testText) { this.testText = testText; }
public String getTestText() { return testText; }
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { return null; }
public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
testText = null;
}
}
4.建立 test.jsp
<%@ page contentType="text/Html; charset=GBK" %
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %
<html:html
<head <title test </title </head
<body bgcolor="#ffffff"
<html:form action="/testAction" onsubmit="return validateTestForm(this);"
testText <html:text property="testText"/
</html:form
<html:javascript formName="testForm"
dynamicjavascript="true"
staticjavascript="false"/
<script language="javascript1.1" src="staticjavascript.jsp"</script
</body
</html:html
5.建立 testAction.java
package test;
import org.apache.struts.action.*;
import javax.servlet.http.*;
public class testAction extends Action {
public ActionForward perform(ActionMapping mapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
return mapping.findForward("test");
}
}
6.Copy 文件:
validation.xml,
validation-rule.xml,
ApplicationResources.properties,
staticjavascript.jsp
7.编缉validate.xml文件(不完整,只要一个Form)
<form name="testForm"
<field property="testText"
depends="required, minlength,maxlength"
<arg0 key="prompt.username"/
<arg1 key="${var:minlength}" name="minlength"
resource="false"/
<arg2 key="${var:maxlength}" name="maxlength"
resource="false"/
<var
<var-namemaxlength</var-name
<var-value16</var-value
</var
<var
<var-nameminlength</var-name
<var-value3</var-value
</var
</field
</form