Struts 2 In Action Sample Application
**Structure of Sample App**
This single Struts 2 web application actually contains a number of
sub-applications. Struts 2 applications, modularized each with their own
configuration files, JSP directories, and Java package space. These
modular applications basically map to the different chapters of the book.
The text of the book always takes pains to point you to the write application.
The home page of the application as a whole has links to the various
sub-applications which pertain to the different chapters.
Note, the first eight chapters have their complete Java source contained
with in chapter specific packages, such as manning.chapterFour. The
latter chapters, starting with Chapter 9, follow this pattern, but break
share a higher level package called manning.utils. Earlier chapters
have their own version of utils, such as manning.chapterFour.utils. This
shouldn't matter to you, but it might be a bit confusing if you don't
know.
**Purpose of the Sample Application**
This sample application aims to provide a thorough and clean demonstration
of all of the core features of the Struts 2 framework, and also provide a real
world case study of a full featured Struts 2 application. The version of the
sample application pertaining to each chapter of the book attempts to focus
the sample code on the lessons at hand. After the introductory HelloWorld
sub-applications, a full featured application will be developed incrementally
through out the course of the book. This application, the "Struts 2 Portfolio",
will increase in complexity with each chapter's contributions. Nonetheless,
the focus of a given chapter's sample code will be on the topics of that
chapter.
When you start the book, the sample application will be rudimentary and
incomplete. The only purpose of early versions is to make the demonstration of
the early core topics unclouded by advanced topics such as Spring integration or
CRUD actions. But by the latter chapters, one can expect that the correspondent
version of the Struts 2 Portfolio to be quite full featured. Though you might
still have to "flip" back to the Chapter Eight version to see how to integrate
Ajax with a custom Result.
**Sample Application Project Structure**
While many people believe that their build and development process may be
standard, there will always be others who believe another set of tools and
practices, which they use, are more standard. We have decided to make an effort
to keep this samplecode build tool and development process independent. The
sample code that you will find zipped with this document is a ready to deploy
war file. It contains all the jar files that it depends on and even contains
its full source code. If you would like to promptly break this apart into an
Ant or Maven project structure, feel free, we certainly would.
All of the source is located in a 'src' directory inside the web application's
WEB-INF folder. This 'src' folder also contains other resources such as
configuration files and properties files. However, the web application comes
fully built and ready to roll.
**Setting up the Application**
There are a few details to attend to if you want everything to run smoothly out
of the box.
Database:
Latter chapters use the Java Persistence API to implement the data layer. As
it stands, this is configured to run with MySQL with a certain username and
password. Configuration of this database connection information is found
entirely at /WEB-INF/applicationContext.xml -- this Spring configuration file.
The early versions of the application will probably still run in the face of
a lack of database connectivity, though you will certainly see errors in the
logs. JPA can pretty much run with any database you might have, so configuring
this shouldn't amount to much. If you choose another database than MySQL,
you'll need to get a driver. In all cases, you'll need to set up the db account
and give it the right privelages.
Filesystem Path:
Another bit of configuration is the path to the file system location for writing
uploaded images. This is set in several places. For early chapters, you can
set this in the sub application's struts.xml file, for example in Chapter 6's
/WEB-INF/classes/manning/chapterSix/chapterSix.xml file. The setting is located
in the declaration element for the ImageUpload action. For latter chapters,
this can be set in the Spring applicationContext.xml file on the bean
declaration element for the portfolioService. The application is set up to
store the uploaded images in an images directory of the web application root.
Unless you are running Debian Linux with the same version of Tomcat, you'll need
to change this if you want Chatpers Nine and up to work.
Default User Accounts:
You will want to log in to the sample application for demoing various features.
In chapters 1-8, you can use one of several built-in accounts. All of these
can be seen by looking in that chapter's PortfolioService class. This class
will be in the util package, such as
manning.chapterThree.utils.PortfolioService. The built-in accounts can be seen
in the static init block that defines the Map of users. You can always count
on the Arty/password (username/password) account.
Struts2 in Action源码
4星 · 超过85%的资源 需积分: 10 125 浏览量
2008-11-19
14:56:38
上传
评论 1
收藏 13.14MB ZIP 举报
joincsdn
- 粉丝: 3
- 资源: 2
最新资源
- 基于STM32使用HAL库实现USB组合设备之多路CDC源码+说明文档.zip
- 金融贸易项目springboot
- mybatis动态sqlSQL 映射 XML 文件是所有 sql 语句
- 基于基于STM32的智能家居系统源码+qt上位机源码.zip
- 深圳房地产资源数据报告
- 基于stm32的智能门禁系统源码+设计文档+演示视频.zip
- cef + chromium 完整源码支持h265和h264
- 基于SpringBoot的API管理平台源代码+数据库,以项目的形式管理API文档,可以进行API的编辑、测试、Mock等操作
- protobuf 3.11版本,静态编译
- 2023NOC创客智慧编程赛项真题图形化-选拔赛(有解析)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
- 5
前往页