struts第一步--HelloWorld项目创建


 

在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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值