用jb9集成struts1.1作一最简单的例子如下:
1.new project;
2.new ->web application;
3.new ->web->ActionForm,name为Untitled1ActionForm,添加一id,其他为默认设置
4.new->web->Action,name为Untitled1Action,FormBean name选第三步建立的formbean,scope->request,validate formbean->false,其他为默认设置
5.new->web->jsp from actionForm name为UntitledJsp1,actionForm选择第三步建立的formbean,其他为默认设置
6.在root directory下新建一jsp1.jsp.
7.修改action代码为:
public ActionForward excute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
return actionMapping.findForward("forward");
}
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="untitled1ActionForm" type="untitled7.Untitled1ActionForm" />
</form-beans>
<action-mappings>
<action name="untitled1ActionForm" type="untitled7.Untitled1Action" validate="false" scope="request" path="/untitled1Action">
<forward name="forward" path="/jsp1.jsp" />
</action>
</action-mappings>
</struts-config>UntitledJsp1部分代码为:
<html:form action="/untitled1Action.do" method="POST">
<html:text property="id"/>
<br>
<html:submit property="submit" value="Submit"/><br>
<html:reset value ="Reset"/>
</html:form>同样做法在struts1.0正常

解决方案 »

  1.   

    去apache站点下载jakarta-struts-1.1.zip
    解压后将webapps下的struts-example.war拷到%tomcat_home%\webapps\下
    启动tomcat
    在地址栏输入http://localhost:8080/struts-example/index.jsp就可以看到运行效果了struts\webapps\下的其他war包的部署方式类似开发自己的struts application,则只需将struts\lib\下的各个jar复制到你自己的web root\WEB-INF\lib下
    然后按照struts的例子,修改web.xml,并添加自己的struts-config.xml到webroot\WEB-INF\下就ok了
    当然,用到标签库的话,还得把相应的.tld文件复制到web.xml中配置的路径中去
      

  2.   

    在webapps有一个blank.war,是一个空的完整struts应用程序,你以它为蓝本,做开发!