wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts.xml file in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts.xml file in Eclipse" Watch "Struts.xml file in Eclipse" New topic
Author

Struts.xml file in Eclipse

pramod talekar
Ranch Hand

Joined: Apr 26, 2010
Posts: 316

Hello,

Could you please tell me where to place struts.xml file in Eclipse.

Thanks,
Pramod


Thanks,
Pramod
vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
Hi Pramod,

Place your struts.xml inside your src folder.

Java Resource src
|---
|--- struts.xml



Regards,
Vanlal
Jaimesh M Ponkia
Greenhorn

Joined: Nov 24, 2010
Posts: 21
For a web project, you can keep your config file in WEB-INF folder and configure the same in web.xml file.
pramod talekar
Ranch Hand

Joined: Apr 26, 2010
Posts: 316

Hi Jaimesh,

So you mean both struts.xml and web.xml should be in WEB-INF??
vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
Hi pramod ,

In your eclipse , struts.xml and web.xml should be in the following location

Java Resource src
|---
|--- struts.xml (under src folder)
|---
Web Content
|--- META-INF
|--- WEB-INF |--- web.xml (under WEB-INF folder)

Regards,
Vanlal
Jaimesh M Ponkia
Greenhorn

Joined: Nov 24, 2010
Posts: 21
Yes. Your web.xml should have the configuration as follows:

Jaimesh M Ponkia
Greenhorn

Joined: Nov 24, 2010
Posts: 21
vanlalhmangaiha khiangte wrote:Hi pramod ,

In your eclipse , struts.xml and web.xml should be in the following location

Java Resource src
|---
|--- struts.xml (under src folder)
|---
Web Content
|--- META-INF
|--- WEB-INF |--- web.xml (under WEB-INF folder)

Regards,
Vanlal


Vanlal,

How would you specify the sturts.xml file path in web.xml if its in the src folder? As far as I know, the web.xml would be able to identify content that is placed within the WebContent folder and nothing outside that.
vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
pramod talekar wrote:Hello,

Could you please tell me where to place struts.xml file in Eclipse.

Thanks,
Pramod


This is the default location in Eclipse .. When you create a new project "dynamic web project" ..
There is no need for a separate init-param in web.xml ..

Moreover in your web.xml

If you use a configuration like the above in your code .. you can place your struts.xml anywhere in your project ...

Regards,
vanlal
Jaimesh M Ponkia
Greenhorn

Joined: Nov 24, 2010
Posts: 21
vanlalhmangaiha khiangte wrote:
pramod talekar wrote:Hello,

Could you please tell me where to place struts.xml file in Eclipse.

Thanks,
Pramod


This is the default location in Eclipse .. When you create a new project "dynamic web project" ..
There is no need for a separate init-param in web.xml ..

Moreover in your web.xml

If you use a configuration like the above in your code .. you can place your struts.xml anywhere in your project ...

Regards,
vanlal

How will struts know what is the name of your configuration file and where is it placed unless you specify it somewhere?
vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
Hi ,

In Struts 2 the struts.xml file has to be in the classpath, not at the root of WEB-INF.
So, in your project, you should put in the "src" folder, so when it deploys it goes into WEB-INF/classes.
You can also verify this ...


Regards,
Vanlal
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Not regarding the IDEs, where should be the struts configuration files reside?


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts.xml file in Eclipse
 
Similar Threads
Unable to load configuration-struts2
There is no Action mapped for namespace / and action name . - [unknown location]
Struts 2 with eclipse
How Struts2.xml is Configured...
Struts 2 error