struts2.0 basic configuration - additional examples

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

Download: http://struts.apache.org/2.1.8.1/index.html

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-2.1.8.1.war, 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 = "http://java.sun.com/xml/ns/j2ee" xmlns: xsi = " http://www.w3.org/2001/XMLSchema-instance "xsi: schemaLocation =" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/ 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" "http://struts.apache.org/ 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!
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of struts2.0 basic configuration - additional examples

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @ gmail.com

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • spring struts2.0 hibernate bug killer 1

    exception There is no Action mapped for namespace / and action name checkLogin. - [Unknown location] com.opensymphony.xwork2.DefaultActionProxy.prepare (DefaultActionProxy.java: 186) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries