`
samsongbest
  • 浏览: 170254 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Using Struts2 from scratch

 
阅读更多

1. Official Website

    http://struts.apache.org/


    Click struts2.3.4(GA) in Documentation
    Click download now
    * Version Notes (包含下面 4 个文件)
    * Full Distribution:
          o struts-2.3.4-all.zip (76mb) [PGP ] [MD5 ]
    * Example Applications:
          o struts-2.3.4-apps.zip (29mb) [PGP ] [MD5 ]
    * Essential Dependencies Only:
          o struts-2.3.4-lib.zip (15mb) [PGP ] [MD5 ]
    * Documentation:
          o struts-2.3.4-docs.zip (33mb) [PGP ] [MD5 ]
    * Source:
          o struts-2.3.4-src.zip (6mb) [PGP ] [MD5 ]


2. 包结构


3. 创建第一个项目

    http://struts.apache.org/2.x/docs/create-struts-2-web-application-with-artifacts-in-web-inf-lib-and-use-ant-to-build-the-application.html

 

Official Seven Steps:

Step 1 - Create A Basic Java Web Application

Step 2 - Add index.jsp and Ant Build File

Step 3 - Add Struts 2 Jar Files To Class Path

Step 4 - Add Logging

Step 5 - Add Struts 2 Servlet Filter

Step 6 - Create struts.xml

Step 7 - Build and Run the Application

 

   a. copy struts-2.2.1\apps\struts2-blank-2.2.1\WEB-INF\lib to /Basic_Struts2_Ant/WebContent/WEB-INF/lib

   b. add filter to 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>

   c. Create struts.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

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

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

		<action name="index">
			<result>/index.jsp</result>
		</action>

	</package>

</struts>

    d. Add Jsp

    e. deploy to tomcat and run the application

    f. open http://localhost:8080/Basic_Struts2_Ant/index.action successful.

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics