struts2 achieve Preparable Interface

2010-09-12  来源:本站原创  分类:Java  人气:159 

Preparable interface has a void prepare () throws Exception method of Action class implementing the interface will approach in the implementation of this action it is executed before prepare (), called the action preparation method.

The other thing on struts2

===============
<package>
===============

struts.xml the name of the package can be defined arbitrarily and only the use of inheritance.

===============
<constent>
===============

struts.xml using <constent name="" value=""/>
Default.proerties the key to change the value of the corresponding

==============================================
Override the default resource file - default.properties
==============================================

You can also clasess (/ src) to establish struts.properties under way, to override the default configuration file default.proerties
Content such as:
struts.i18n.encoding = gbk character set set
struts.action.extension = do set the request name suffix
struts.configuration.files = struts-default.xml, struts-plugin.xml, struts.xml Struts2 automatically loads the configuration file

==============
Abstract package
==============
<package
name="..." abstract="true">
That the definition of the package can not have action can only be defined through the package to inherit

=============
Namespace
=============
<package
name="..." namespace= "">
Application to separate the different configuration if you do not, that the current package in a default namespace

namespace = "/ hello"
Request to change the path to / hello / register

Need to change the path of the form and must be manually added. Action
<s:form action="/hello/register.action">

Find ways, if the namespace as the default, and form path is / hello / register.action
When the struts did not find the namespace is automatically to the default namespace to find

=============================
<include> modular configuration
=============================

<include file="struts_1.xml"> </ include>
<include file="struts_2.xml"> </ include>

struts_1.xml and struts_2.xml are standard strust the xml configuration file
include post, struts will start after struts_1.xml and struts_2.xml loaded with configuration information into memory.

===============
Struts2 MVC
===============
FilterDispatcher ----- core controller

Business controller for each action -------
--------- ---- Call business logic component called DAO ---- Database interaction

=================
Sub-Module Development
=================

established under src
struts1.xml
struts2.xml

Different developers, just write your own xml configuration file only needs to struts.xml in
<Include file = "struts1.xml" />
<Include file = "struts2.xml" />

----------------
struts1.xml
xml declaration, DTD structure and struts.xml the same information ...
<struts>
<package name="" ...>
...
...
...

----------------
struts2.xml
xml declaration, DTD structure and struts.xml the same information ...
<struts>
<package name="" ...>
...
...
...

================
Model-driven
================

** Attributes Driver **: form fields exist as attributes of Action

** ** Model-driven: to load the object with a similar ActionForm JavaBean

Model Bean
public class User (
private String username;
private String password;
private String repassword;
private int age;
private Date date;

/ / Setter ... getter ...
)

# # # ValueStack # # # - the value stack

ModelDriven <T> the use of generic interfaces,
What type of model is that of generic types
------ T getModel ()

Action needed to achieve ModelDriven Interface

public class RigesterAction extends ActionSupport
implements ModelDriven <User> (

private User user = new User ();
public User getModel () (
return user;
)

@ Override
public String execute () throws Exception (

return SUCCESS;
)
)

====================
Preparable Interface
====================

Preparable interface has a void prepare () throws Exception method of Action class implementing the interface will approach in the implementation of this action it is executed before prepare (), called the action preparation method.

=========================
Show specific error message
=========================

<s:fielderror cssStyle="color:red">
<S: param> username </ s: param>
</ S: fielderror>

Remove the front of the "origin"
Need to get rid of your template before modify fielderror.ftl point code

相关文章
  • struts2 achieve Preparable Interface 2010-09-12

    Preparable interface has a void prepare () throws Exception method of Action class implementing the interface will approach in the implementation of this action it is executed before prepare (), called the action preparation method. The other thing o

  • Struts2 of Preparable Interface 2010-09-21

    Struts2 of Preparable Interface Struts2 in Action in achieving com.opensymphony.xwork2.Preparable interface, you can rewrite the prepare () method in Action at this time in, prepare () method implementation is in: setXxx () and execute () before the

  • String3 and Struts2 of ServletContextAware Interface 2010-07-23

    In the Spring + Struts projects, Spring and struts can be coupled Servlet. However, the class of non-Action, if implemented Struts2 of ServletContextAware interface, the call String filepath = servletContext.getRealPath("/"); Take less than the

  • "Reprinted> struts2 achieve remove the suffix and the url rewrite" / reproduced " 2008-12-31

    To remove the suffix in the struts2 to achieve and url rewriting Keyword: struts2 2009-06-21 13:10 First, it use to the two packages, one SmartUrls (Struts2 plug-in, download address: http://code.google.com/p/smarturls-s2/downloads/list), there is a

  • javaBean achieve Serializable interface, why? 2010-08-13

    Java's "Object Serialization" lets you interface that implements the Serializable object into a byte, so in the future to use this object, you will be able to come out of these byte data recovery, and accordingly re-build the object. This is eve

  • Struts2 ModelDriven Preparable 2010-07-14

    paramsPrepareParamsStack in Struts 2.0 is a very wonderful interceptor stack, so many people question why it was not set as the default interceptor stack. paramsPrepareParamsStack ModelDriven and Preparable mainly solved the co-ordination, literally,

  • Struts2 achieve form data downloaded to Excel, 2010-03-23

    // The core code HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("application/vnd.ms-excel"); String fileName = java.net.URLEncoder.encode(" Employee information .xls", "UTF-8"); res

  • To achieve an interface, and the combination of the difference between an interface 2010-07-03

    /* You can see from the code, the first wording ,A Is bound to a particular implementation of BBB The second way, in A BBB The implementation is dynamically bound . */ Class A implements BBB{ public void BBB_1(){ } } Class A{ BBB b ; public void setB

  • C # interface to the display to achieve the realization and implicit 2010-09-27

    Interface to achieve a lot of people know, but Way of display interface implementation to achieve and the implicit realization do not know if many people know it! But I feel the company's technology department made little reference to this, wanted to

  • Android to achieve interface refresh (Reprinted) 2011-01-02

    Android provides the interface to refresh Invalidate method implementation, but not directly in the thread Invalidate calls, because he is a violation of single-threaded model: Android UI is not thread-safe operation, and these operations must be in

  • Struts projects will be moved to Struts2 (b) 2009-09-25

    <! - StartFragment -> Please Fuzheng heroes Migrating to Struts 2 - Part II In the first part of this series , We explained (for Struts developers) the high level architecture, basic request workflow, configuration semantics and differences in the a

  • Struts2 interceptor Details 2010-03-29

    Struts2 related to struts-default.xml, struts.xml, struts.properties file Xiangjie each study a framework, we will inevitably have to learn some information about the configuration file, struts2 no exception, here I will talk about several key struts

  • Struts2 + Spring + iBatis on the web application of best practices series of four (CRUDL articles) 2010-03-29

    Let us first look at what is CRUD, CRUD or Create-Read-Update-Delete the English abbreviation, but I would also like to add one here, L, namely List, combine to make up CRUDL. CRUDL this scenario or model are common among most of the applications, th

  • Struts2 Interceptor (Interceptor) 2010-03-29

    1. Understand the interceptor 1.1. What is the interceptor: Interceptors, in the AOP (Aspect-Oriented Programming) is used in a method or field has been visited before, before or after the block and then adding some operations. AOP interception is an

  • Struts2 interceptor 2010-03-29

    Interceptor-Exception Editor: http://blog.csdn.net/wmj2003/archive/2008/11/06/3236981.aspx <interceptor name="exception"/> Configuration Exception, what kind of exception if the jump to the corresponding page. After the implementation of t

  • Struts2 related to struts-default.xml, struts.xml, struts.properties file Xiangjie 2009-03-21

    Each study a framework, we will inevitably have to learn some information about the configuration file, struts2 is no exception, here I will talk about several major struts2 configuration file. 1) struts-default.xml This file is the struts2 framework

  • Using struts2 interceptor 2008-05-23

    How to use struts2 interceptors, or the custom interceptors. Special attention in the use of interceptors, when, in the Action which must finally be sure to reference the interceptor struts2 own default stack defaultStack, as follows (where I was quo

  • Such as labels on the struts2 of checkboxlist.select occurred could not be resolved as a collection / array / ma 2010-04-28

    Today the label features of struts2, when in use checkboxlist, Code is as follows <s:select name="cardsortId" list="cardsortList" listKey="csId" listValue="cardname" theme="simple"></s:select>

  • The principle of Struts2 interceptor and Implementation 2010-06-06

    * The principle of Struts2 interceptor and Implementation * [Url] http://developer.51cto.com [/ url] 2009-06-04 08:01 Struts2 Struts2 interceptor is a very important function. This concept from the beginning, as we explained Struts2 interceptor imple

  • Struts2 interceptor built a brief description of 2010-09-07

    Struts2 interceptor built a brief description of alias (alias blocker): Allow parameters across multiple requests using a different alias, the interceptor can be used many different names to link Action, and then used to process the same information.