Click here to Skip to main content
15,891,253 members
Home / Discussions / Java
   

Java

 
GeneralRe: Connection to SQL using JDBC in Java Pin
Richard MacCutchan28-Jun-13 5:14
mveRichard MacCutchan28-Jun-13 5:14 
GeneralRe: Connection to SQL using JDBC in Java Pin
chdboy28-Jun-13 5:17
chdboy28-Jun-13 5:17 
GeneralRe: Connection to SQL using JDBC in Java Pin
Richard MacCutchan28-Jun-13 6:00
mveRichard MacCutchan28-Jun-13 6:00 
GeneralRe: Connection to SQL using JDBC in Java Pin
chdboy28-Jun-13 6:16
chdboy28-Jun-13 6:16 
GeneralRe: Connection to SQL using JDBC in Java Pin
Richard MacCutchan28-Jun-13 6:45
mveRichard MacCutchan28-Jun-13 6:45 
GeneralRe: Connection to SQL using JDBC in Java Pin
chdboy28-Jun-13 6:46
chdboy28-Jun-13 6:46 
QuestionHow to implement a Struts project with Spring together? Pin
JasminHan25-Jun-13 18:22
professionalJasminHan25-Jun-13 18:22 
AnswerRe: How to implement a Struts project with Spring together? Pin
Arindam Mondal from India28-Jun-13 6:56
Arindam Mondal from India28-Jun-13 6:56 
I am assuming you are using Struts 1.x and Spring 2.5.x and able to solve jar dependency by your own.

If you have to integrate Struts with Spring you can follow this approach. This is the simplest way to integrate those two.

1. First you have to register spring ready-made struts plug-in in the struts-config.xml. Other things will be remain the same.
XML
 <struts-config>
   <plug-in  className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
		value="/WEB-INF/classes/ApplicationContext.xml" />
  </plug-in>
</struts-config>

The ContextLoaderPlugIn will handle all the integration work between Struts and Spring.

2. Inside your ApplicationContext.xml you have to mention all the Service and DAO and other stuff, what you want manage by Spring.
XML
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="someService" class="com.some.Service.SomeService" >
 <property name="someDao" ref="someDao" />
</bean>
</beans>

3. All struts action class must extends spring ActionSupport instead of extending struts action. This will make the spring bean available via getWebApplicationContext() method.
Java
public class SomeAction extends ActionSupport{

public ActionForward execute(ActionMapping mapping,ActionForm form, HttpServletRequest request,HttpServletResponse response) 
        throws Exception {
SomeService someService =
		(SomeService) getWebApplicationContext().getBean("someService");

Now you can invoke spring service from struts.
GeneralRe: How to implement a Struts project with Spring together? Pin
JasminHan30-Jun-13 22:03
professionalJasminHan30-Jun-13 22:03 
GeneralRe: How to implement a Struts project with Spring together? Pin
Arindam Mondal from India1-Jul-13 3:54
Arindam Mondal from India1-Jul-13 3:54 
Questionreading and writing using smartcard?? Pin
Sairam3925-Jun-13 0:36
Sairam3925-Jun-13 0:36 
QuestionBeginner in Java. I want to test my knowledge Pin
Adrian Manuel Tan Cleofe22-Jun-13 16:51
Adrian Manuel Tan Cleofe22-Jun-13 16:51 
AnswerRe: Beginner in Java. I want to test my knowledge Pin
Richard MacCutchan22-Jun-13 23:51
mveRichard MacCutchan22-Jun-13 23:51 
AnswerRe: Beginner in Java. I want to test my knowledge Pin
JasminHan25-Jun-13 18:43
professionalJasminHan25-Jun-13 18:43 
AnswerRe: Beginner in Java. I want to test my knowledge Pin
MarlBermudoNights3-Jul-13 22:31
professionalMarlBermudoNights3-Jul-13 22:31 
QuestionJava application path in Eclipse juno show wrong neet to set correct Pin
Balmukund Dewangan21-Jun-13 4:21
Balmukund Dewangan21-Jun-13 4:21 
AnswerRe: Java application path in Eclipse juno show wrong neet to set correct Pin
Richard MacCutchan21-Jun-13 5:25
mveRichard MacCutchan21-Jun-13 5:25 
GeneralRe: Java application path in Eclipse juno show wrong neet to set correct Pin
Balmukund Dewangan21-Jun-13 6:32
Balmukund Dewangan21-Jun-13 6:32 
GeneralRe: Java application path in Eclipse juno show wrong neet to set correct Pin
Richard MacCutchan21-Jun-13 6:56
mveRichard MacCutchan21-Jun-13 6:56 
GeneralRe: Java application path in Eclipse juno show wrong neet to set correct Pin
Balmukund Dewangan21-Jun-13 18:11
Balmukund Dewangan21-Jun-13 18:11 
GeneralRe: Java application path in Eclipse juno show wrong neet to set correct Pin
Balmukund Dewangan21-Jun-13 21:17
Balmukund Dewangan21-Jun-13 21:17 
GeneralRe: Java application path in Eclipse juno show wrong neet to set correct Pin
Richard MacCutchan21-Jun-13 21:59
mveRichard MacCutchan21-Jun-13 21:59 
GeneralRe: Java application path in Eclipse juno show wrong neet to set correct Pin
Balmukund Dewangan21-Jun-13 22:31
Balmukund Dewangan21-Jun-13 22:31 
GeneralRe: Java application path in Eclipse juno show wrong neet to set correct Pin
Richard MacCutchan22-Jun-13 0:59
mveRichard MacCutchan22-Jun-13 0:59 
QuestionWebservice in Java Pin
Ganeshbabu.R21-Jun-13 2:27
professionalGaneshbabu.R21-Jun-13 2:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.