Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

Struts2 Interview Questions and Answers For Graduates Part-4

Be First!

struts 231.What should be the name of xml file used for validation in struts?
The xml file needs to be named ‘[action-class]’-validation.xml.

32.What types of validations are available in xml based validation in struts2?
Following is the list of various types of field level and non-field level validation available in Struts2 −

date validator

double validator

email validator

expression validator

int validator

regex validator

required validator

requiredstring validator

stringlength validator

url validator

33.What is Internationalization?
Internationalization (i18n) is the process of planning and implementing products and services so that they can easily be adapted to specific local languages and cultures, a process called localization. The internationalization process is sometimes called translation or localization enablement.

34.How struts2 supports Internationalization?
Struts2 provides localization ie. internationalization (i18n) support through resource bundles, interceptors and tag libraries in the following places −

The UI Tags.

Messages and Errors.

Within action classes.

35.What is the naming convention for a resource bundle file in struts2?
The simplest naming format for a resource file is −

bundlename_language_country.properties
Here bundlename could be ActionClass, Interface, SuperClass, Model, Package, Global resource properties. Next part language_country represents the country locale for example Spanish (Spain) locale is represented by es_ES and English (United States) locale is represented by en_US etc. Here you can skip country part which is optional.

36.In which order Struts framework searches for a message bundle?
When you reference a message element by its key, Struts framework searches for a corresponding message bundle in the following order −

ActionClass.properties

Interface.properties

SuperClass.properties

model.properties

package.properties

struts.properties

global.properties

37.Which class of struts is responsible to converts data types from string and vice versa?
StrutsTypeConverter class tells Struts how to convert Environment to a String and vice versa by overriding two methods convertFromString() and convertToString().

38.What inbuilt themes are provided by Struts2?
Struts 2 comes with three built-in themes −

simple theme − A minimal theme with no “bells and whistles”. For example, the textfield tag renders the HTML <input/> tag without a label, validation, error reporting, or any other formatting or functionality.

xhtml theme − This is the default theme used by Struts 2 and provides all the basics that the simple theme provides and adds several features like standard two-column table layout for the HTML, Labels for each of the HTML, Validation and error reporting etc.

css_xhtml theme − This theme provides all the basics that the simple theme provides and adds several features like standard two-column CSS-based layout, using <div> for the HTML Struts Tags, Labels for each of the HTML Struts Tags, placed according to the CSS stylesheet.

39.How to handle exceptions in Structs?
Struts makes the exception handling easy by the use of the “exception” interceptor. The “exception” interceptor is included as part of the default stack, so you don’t have to do anything extra to configure it. It is available out-of-the-box ready for you to use.

40.What is the purpose of @Results annotation?
A @Results annotation is a collection of results. Under the @Results annotation, we can have multiple @Result annotations.

@Results({
@Result(name=”success”, value=”/success.jsp”),
@Result(name=”error”, value=”/error.jsp”)
})
public class Employee extends ActionSupport{

}

(145)

Previous
Next

Leave a Reply