70663

How does Struts create an action bean?

Question:

I use Struts2.x and I know that Struts creates the declared bean objects in the action based on the request so that it is available to the action. I have been researching to understand which interceptors/classes does Struts use internally to create the bean object. I am trying to understand the logic that is used internally for creation of the bean objects. Does it use PropertyUtils to populate properties for the beans or some other way? Any suggestion or pointers for reading will be helpful.

Answer1:

Internally Struts uses the ObjectFactory to build all objects defined by the configuration. See more about <a href="http://struts.apache.org/docs/objectfactory.html" rel="nofollow">ObjectFactory</a> docs or <a href="http://struts.apache.org/docs/the-struts-2-request-flow.html" rel="nofollow">The Struts 2 Request Flow</a>.

When you populate some bean using <a href="http://struts.apache.org/release/parameters-interceptor.html" rel="nofollow">params</a> interceptor it will by default create objects if they not exist with the help of <a href="http://struts.apache.org/docs/ognl.html" rel="nofollow">OGNL</a>. It's also configurable.

PropertyUtils isn't used by the Struts2 core, but could be used by plugins if they need a commons-beanutils package.

Recommend

  • handling $http.get and $http.post errors in Angularjs
  • Spring 3 mvc:resources causing mvc:interceptors to run multiple times
  • Google Contacts API asp.net settings and authorization token
  • Retrieve google contact based on contact Id
  • How can I substitute my own custom dynamic scaffolding methods
  • How to run .ear file in JBoss 6?
  • Camel REST Bean Chaining
  • How do I chomp a string if I have Perl 4?
  • IllegalArgumentException caught when parsing URL with JSON String
  • Vim folding : how to hide all the single lines not containing a search pattern (or fold zero line)?
  • When is locking on types a good idea?
  • ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn&
  • Is it safe to accept URL parameters for populating the `url_for` method?
  • Search function not doing anything
  • Creating UDF with VSTO in Excel
  • How to set an entity field that does not exist on the table but does exists in the raw SQL as an ali
  • how to query for min or max inet/cidr with postgres
  • How to add closing tag for canvas in three js rendered Canvas?
  • sweetalert2 inputoptions from file in select example
  • Does Apportable support to build library binary (.a/.so)?
  • Why use database factory in asp.net mvc?
  • Can someone please explain to me in the most layman terms how to use EventArgs?
  • RxJava debounce by arbitrary value
  • gspread or such: help me get cell coordinates (not value)
  • onBackPressed() not being executed
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Q promise. Difference between .when and .then
  • ActionScript 2 vs ActionScript 3 performance
  • Statically linking a C++ library to a C# process using CLI or any other way
  • AT Commands to Send SMS not working in Windows 8.1
  • Comma separated Values
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • python regex in pyparsing
  • Error creating VM instance in Google Compute Engine
  • C# - Getting references of reference
  • Hits per day in Google Big Query
  • Why joiner is not used after Sequence generator or Update statergy
  • how does django model after text[] in postgresql [duplicate]
  • How do I configure my settings file to work with unit tests?
  • Is it possible to post an object from jquery to bottle.py?