With Spring injection in struts2,action, the injection succeeds when the service is started, and the action Run-time object becomes null __spring

Source: Internet
Author: User

Meet a person in the software group: Ask the big God a problem, in the SSH framework, the action in spring injection, start the service injected success, the action Run-time object to become null, this is how AH.
The problem: After looking at his profile, he found that he used spring's dependency injection Applictioncontext.xml has a related bean configured, but when you configure the action in a struts2 file, you use the full path of the class, not the bean that references spring.
Solution: The problem has been found, it is good to do, in the Struts2 configuration file to change the action class value to the appropriate bean.
As shown in the figure:

Key position of Applictioncontext.xml

Key position of Struts.xml

Modified into

<action name= "Login" class= "useraction" mentod= "Login" >

<result name= "Success" type= "redirect" >main.jsp</result>

<result name= "fail" type= "redirect" >pass.jsp</result>

</action>

Problem solving ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.