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!

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

相关文章

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.303 (s). 14 q(s)