Action is: public class Registaction {private Iregistservice iregistservice;
Private Sshuser Sshuser;
Public String Registuser () {System.out.println ("=========>" +iregistservice);
Iregistservice.registuser (Sshuser);
Return "Success"; Struts configured as: <?xml version= "1.0" encoding= "UTF-8"?> <! DOCTYPE struts Public "-//apache Software foundation//dtd struts Configuration 2.1//en" "http://struts.apache.org/dtds/ Struts-2.1.dtd "> <struts> <!--<include file=" Struts-default.xml "></include>--> &L t;! --This sentence is to give struts to spring management--> <constant name= "struts.objectfactory" value= "Spring" ></constant> < Package Name= "Sshtestpackage" extends= struts-default "namespace="/"> <action name=" registaction "class=" Regis Taction "method=" Registuser "> <result name=" Success ">/hello.html</result> </action> &L The reason the service in T;/package> </struts> action can't be injected is that struts is not delivering spring hosting, &The role of Lt;constant name= "Struts.objectfactory" value= "Spring" ></constant> is to deliver struts to spring hosting, while The action's class must be changed to the ID name of the action in the Spring configuration file