一
在Myecliipse的Package下创建一个Web Project,命名为HelloStructs,
J2EE Specification Level 下选择Java EE5.0.
二
在Myeclipse -->preferences下配置,选择MyEclipse-->Server-->Tomcat
根据安装的版本选择 .这里我选择Tomcat 7.x.选择Tomcat server:Enabled
在Tomcat home directory设置Tomcat的安装目录
三
在安装的struts-2.3.4.1目录下选择apps,解压structs2-blank
在structs2-blank下选择WEB-INF-->classes--拷贝structs.xml到项目下的src下
四
在structs2-blank下选择lib,拷贝其中的所有压缩包到项目 的WebRoot-->WEB-INF->lib文件 夹下
五
在structs2-blank下选择WEB-INF下的web.xml.打开,拷贝其中的
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
到WebRoot-->web.xml
六修改src/structs.xml
将structs标签内的代码都注释掉,以做为参考
拷贝package标签中的内容到structs标签下,修改如下
<package name="default" namespace="/"extends="struts-default">
<action name="hello">
<result>
/index.jsp
</result>
</action>
</package>
七,修改index.jsp下的内容
在body中添加标签<p>hello,structs,I am coming</p>
八,调试,运行
在项目右键,Debug As-->Myeclipse Server Application
在弹出的选择框中选择Tomcat 7.x以启动tomcat
在Myeclipse下的Web Brower下的Location输入http://localhost:8080测试tomcat是否启动成功
如果成功,再测试项目
在Location下输入http://localhost:8080/hello.cation
或者http://localhost:8080/hello [hello是structs.xml下的package下的action的name值]
或者http://localhost:8080/HelloStructs2/index.jsp