is it necessary to write struts-confing.xml ,what tags are
important in that xml file?

Answers were Sorted based on User's Feedback



is it necessary to write struts-confing.xml ,what tags are important in that xml file?..

Answer / rajasekhar

Yes, it is necessary to provide the configuration file. But
it is not compulsary that the name of the file should be
struts-config.xml. We need to configure the name of the
file in the deployment descreptor(web.xml) of the web
application.

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet </servlet-
class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-
value>
</init-param>.....
<servlet>

Important tag in the configuration files are:
<struts-config>
<form-beans>
<form-bean name=" employForm" class="com.emp.EmployForm"/>
</form-beans>
<global-forwards>
<forward name="success" path="success.jsp" />
</global-forwards>
<global-exceptions>
<excetption key="some.key" type="ExceptionType"
path="SomeException.jsp" />
</global-exception>
<action-mappings>
<action path="/login" name="employForm"
type="com.emp.EmployAction" scope="request\session"
input="/login.jsp" validate="true/false" >
<forward name="success" path="/Mainpage.jsp" />
<forward name="failure" path="/Errorpage.sp" />
</action>
</action-mappings>
<controller
processorClass="org.apache.struts.action.RequestProcessor"/>
<message-resource parameter="applicationResources" />
</struts-config>

Is This Answer Correct ?    20 Yes 0 No

is it necessary to write struts-confing.xml ,what tags are important in that xml file?..

Answer / pradip mishra(geit dehradun(b-

yes but it is not necessarly to import alwase in struts-
config.xml, u may change on web.xml<?xml version="1.0"
encoding="UTF-8" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts
Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-
config_1_2.dtd">


<struts-config>
<form-beans>
<form-bean name="NewStrutsActionForm"
type="p.NewStrutsActionForm"/>

</form-beans>

<global-exceptions>

</global-exceptions>

<global-forwards>
<forward name="welcome" path="/Welcome.do"/>
</global-forwards>

<action-mappings>
<action input="/welcomeStruts.jsp"
name="NewStrutsActionForm" path="/xx" scope="session"
type="p.NewStrutsAction">
<forward name="success"
path="/welcomeStruts.jsp"></forward>
<forward name="fail"
path="/Hello1.jsp"></forward>
<forward name="s12"
path="/welcomeStruts.jsp"></forward>
</action>



<action path="/Welcome"
forward="/welcomeStruts.jsp"/>
</action-mappings>

<controller
processorClass="org.apache.struts.tiles.TilesRequestProcesso
r"/>

<message-resources
parameter="com/myapp/struts/ApplicationResource"/>

<!-- ========================= Tiles plugin
===============================-->
<!--
This plugin initialize Tiles definition factory. This
later can takes some
parameters explained here after. The plugin first read
parameters from
web.xml, thenoverload them with parameters defined
here. All parameters
are optional.
The plugin should be declared in each struts-config
file.
- definitions-config: (optional)
Specify configuration file names. There can be several
comma
separated file names (default: ?? )
- moduleAware: (optional - struts1.1)
Specify if the Tiles definition factory is module
aware. If true
(default), there will be one factory for each Struts
module.
If false, there will be one common factory for all
module. In this
later case, it is still needed to declare one plugin
per module.
The factory will be initialized with parameters found
in the first
initialized plugin (generally the one associated with
the default
module).
true : One factory per module. (default)
false : one single shared factory for all modules
- definitions-parser-validate: (optional)
Specify if xml parser should validate the Tiles
configuration file.
true : validate. DTD should be specified in file header
(default)
false : no validation

Paths found in Tiles definitions are relative to the
main context.
-->
<plug-in
className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>

<!-- ========================= Validator plugin
================================= -->
<plug-in
className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-
INF/validation.xml"/>
</plug-in>

</struts-config>

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More Struts Interview Questions

What is controller in struts ?

0 Answers  


its a ActionForm controller or model?

16 Answers   Patni, TCS, Wipro,


What do you mean by actionform?

0 Answers  


What is the difference between validation.xml and validator-rules.xml files in struts validation framework?

0 Answers  


what is diffrence between Dynaactionform,actionform and Dynavalidateform

8 Answers   TCS,






What is the purpose of redirect result type?

0 Answers  


Hi i am murali.i need a excellent answer for the question Tell me about project and project flow ? i mean it is use full to any project,it is on STRUTS

2 Answers  


What is the role of a handler in mvc based applications?

0 Answers  


What is controller in struts2?

0 Answers  


What are different ways to create Action classes in Struts2?

0 Answers  


Where can I get a copy of struts?

0 Answers  


what are the struts tags?

1 Answers  


Categories