struts2.0 basic configuration - additional examples

The role of struts, said little, and it served as the role of MVC in the C


Started building a struts2.0 following example:

1, extract the archive to download good struts2 find directory the following apps directory to the apps directory below to find struts2-blank-, unzip it, unzip to the WEB-INF directory to find the following lib files folder, which has 6 jar pack, as shown below:

struts2.0 basic configuration - additional examples

The red box of 5 jar package is build a few packages strut2.0 framework must!

2, create a new MyEclipse web project, the above six packages copied to WebRoot / WEB-INF / lib the following

3, modify web.xml file, of course, can also be downloaded directly from the copied struts project

<? Xml version = "1.0" encoding = "UTF-8"?> <Web-app version = "2.4" xmlns = "" xmlns: xsi = " "xsi: schemaLocation =" j2ee/web-app_2_4.xsd "> <display-name> Struts Blank </ display-name> <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 > <welcome-file-list> <welcome-file> index.jsp </ welcome-file> </ welcome-file-list> </ web-app>

4, in the src directory create a struts.xml the following documents can also download the struts project copied, struts.xml:

<? Xml version = "1.0" encoding = "UTF-8"?> <! DOCTYPE struts PUBLIC "- / / Apache Software Foundation / / DTD Struts Configuration 2.0 / / EN" " dtds/struts-2.0.dtd "> <struts> <! - set ui style -> <constant name="struts.ui.theme" value="simple" /> <! - set to development mode - > <constant name="struts.devMode" value="false" /> <! - Set the file encoding of internationalization -> <constant name = "struts.i18n.encoding" value = "UTF-8" / > <! - set the international document -> <constant name="struts.custom.i18n.resources" value="messageResource"/> <constant name="struts.i18n.reload" value="true" /> <! - this place can contain sub-module configuration -> <!--< include file = "user_struts.xml "/>--> <! - The following are examples of Action configuration -> <package name = "user" namespace = "/" extends = "struts-default"> <! - Registration start -> <action name="Register"> <result name="input"> / pgRegister.jsp </ result> <result name="success"> / pgRegister.jsp </ result> <result name="error"> / pgRegister.jsp </ result> </ action> <! - Registration end -> <! - Login start -> <action name="Login"> <result name="input"> / pgLogin.jsp </ result> <result name="success"> / pgLoginSuccess.jsp </ result> <result name = "error "> / pgLogin.jsp </ result> </ action> <! - log end -> </ package> </ struts>

The following can use struts2 it!

Add a small example, see Annex!

分类:Java 时间:2010-08-05 人气:199
blog comments powered by Disqus


  • maven2: created from the archetype of existing projects 2009-10-14

    Recent spring2.5.6 + hibernate3.2 + struts2.0.14 do projects, so use the framework of the project is the most troublesome ghosts to build the basic prototype of the project, in order to not have in the future in such trouble, so there will be a creat

  • Use Maven + Eclipse + Tomcat Summary 2010-03-29

    The development, the initial preparations for the introduction of maven, the original development environment is Eclipse + Tomcat. Other functions because of maven is not very familiar with the original use it would only rely on the management functi

  • Graphic description xfire webservices detailed steps (with source code) 2010-03-23

    The working environment Eclipse3.3 + tomcat6 + xFire1.2.6 In this paper, recorded in the Eclipse step by step how to create xFire webservices detailed steps: Examples of source code: webservices_xfire_demo XFire official website http://xfire.codehaus

  • Graphic description xfire webservices detailed steps (with source code) "transfer" 2010-03-25 The working environment Eclipse3.3 + tomcat6 + xFire1.2.6 In this paper, recorded in the Eclipse step by step how to create xFire webservices detailed steps: Examples of source code: webservices_xfire_demo XFire of

  • maven2 form a template framework 2010-04-28

    maven2: create archetype from an existing project Keywords: maven2 archetype ssh Recently with spring2.5.6 + hibernate3.2 + struts2.0.14 a project, a project with these frameworks is the most troublesome gh

  • struts-2.0.14 + spring-2.5.6 + hibernate-3.2.6 integration 2010-05-04

    1 jar package into struts2 jar package ognl-2.6.11.jar, struts2-core-2.0.14.jar, xwork-2.0.7.jar, commons-logging-1.0.4.jar, freemarker-2.3.8.jar, struts2-tiles-plugin- 2.0.14.jar hibernate 3.2 jar package antlr-2.7.6.jar, commons-collections-2.1.1.j

  • jboss seam optimization, configuration web.xml 2010-07-14

    seam to do the project, with the war package, for some richface and ajax4jsf optimization, simply put the whole xml have come, but that does not slow page response, we see there are other optimization you need to <?xml version="1.0" encoding=

  • Use PHP to master Facebook Application Development 2010-09-09

    Application, an application to the Java ™ code. Before you begin About this series Rational Application Developer, Zend Core for IBM, PHP 5, and DB2. You will use Java and PHP 5 are part of the code written. Performance of an existing stockbroker com

  • Maven new packaging standards such as Eclipse Dynamic Web Project Management 2010-09-13

    Maven can not do without POM file (project object model, XML documents). Generate Eclipse JAVA project with Maven is very convenient, almost completed the formation does not require any custom work done (in addition to increased reliance). To generat

  • basic configuration struts2 2010-09-24

    1.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="" xmlns="" xmlns:web="

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.031 (s). 13 q(s)