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 人气:192
blog comments powered by Disqus


  • Android: the new layout of the xml file can not be file reception problems 2010-10-07

    Note the new layout of the xml file name uppercase letters can not and must meet a series of specifications!

  • Linux, copy the. Delete and rename files or folder 2010-10-20

    Copy files and subdirectories: cp-r folder a new path Typically, delete the file using: rm filename Delete the folder with: rmdir folder name However, non-empty rmdir can not remove the folder, how to delete non empty folder it: Command: rm-rf non-em

  • Copying under Linux. Delete and rename files or folder 2010-10-20

    Copy files and subdirectories: cp-r folder a new path Typically, delete files with: rm filename Delete the folder with: rmdir folder name But rmdir can not remove non-empty folder, how to delete empty folders it: Command: rm-rf non-empty folder name

  • 为了生成只读的接口和xml,并命名结尾为MapperR.java和MapperR.xml 2015-03-23

    <一>首先从下载源代码,然后找到org.mybatis.generator.api下面的IntrospectedTable文件,修改以下两个方法,然后重新打个jar包. 1.修改calculateJavaClientAttributes方法 protected void calculateJavaClientAttributes() { if (context.getJavaClientGeneratorConfigura

  • Configured in context.xml made the connection pool of Java code written 2010-08-18

    7. Bind (String name, Object obj) He is equivalent to the jndi factory, he hides the details of the product created, use the time I get on it directly. 8. Ctx.lookup ("jdbc / drp"); you can not get away with ah that was in front and a string, th

  • 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=

  • 使用axis2 services.xml 发布web service 2013-03-18

    之前转的使用Pojo来发布webservice,使用有限制,不能发布带包的Pojo,所以找了使用services.xml发布项目的方式. package service; public class MyService { public String getHello(String name) { return "您好 !" + name; } public void update(String data) { System.out.println("<" +

  • web.xml报错:Invalid content was found starting... 2013-04-30

    web.xml报错Invalid content was found starting with element 'init-param'. 原文来自: 转载到这里作为备用,转载请注明原文出处. 编辑web.xml文件时, <? xml version="1.0" encoding="UTF-8" ?> < web-app xmlns:xs

  • 使用JAXB处理XML文档--先睹为快 2012-03-09

    JAXB以其方便的XML数据处理能力可能会引起你的兴趣.你可能还不了解JAXB是什么,想要知道它到底有 什么好处,如果这是你需要的,你才会再花时间去细细的研究它,或者你只需要使用最基本的功能.然而Sun关于JAXB的文档有80页之多.我想大部分人都 没有耐心看完这样的长篇大论.本文以简短的篇幅介绍了JAXB的基本使用,算是先睹为快吧.本文附带的代码包括了JAXB1.0 early access版本和本文所使用的代码.欢迎与我讨论: 本文假设你会

  • 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

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 黔ICP备15002463号-1

processed in 0.250 (s). 12 q(s)