码迷,mamicode.com
首页 > 其他好文 > 详细

struts2 入门程序

时间:2016-08-18 06:28:21      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

1、struts 2.5.2

基本jar包

 技术分享

 

2、web.xml

 技术分享

 

 

<!-- Filters -->

  <!-- START SNIPPET: filter -->

    <filter>

        <filter-name>struts252</filter-name>

        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>

    </filter>

    <!-- END SNIPPET: filter -->

 

    <filter-mapping>

        <filter-name>struts252</filter-name>

        <url-pattern>/*</url-pattern>

</filter-mapping>

 

 

  org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter    struts>=2.5使用

 

3、struts.xml

在source floder下

<?xml version="1.0" encoding="UTF-8" ?>

 

<!DOCTYPE struts PUBLIC

   "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"

   "http://struts.apache.org/dtds/struts-2.5.dtd">

<struts>

<package name="myPackage" extends="struts-default">

<action name="first">

<result>/first.jsp</result>

</action>

</package>

</struts>

 

热部署, 开发时,可打开开发模式。

<constant name="struts.devMode" value="true" />

4、JSP

 技术分享

 

5、测试

访问http://localhost:8080/struts2/first或http://localhost:8080/struts2/first.action

 技术分享

 

struts2 入门程序

标签:

原文地址:http://www.cnblogs.com/jway1101/p/5782524.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!