Struts2.0 framework Configuration File

Struts2.0 framework Configuration File

Previous Home Next

 

The struts2 configuration file described the all request which is send by user then configure action class will be invoked . The action class return the string this string is configure in configuration file then send the response with the help of Result class. 

 There are two ways to do configuration file in struts2 framework

First XML based configuration file:-

struts.xml

<!DOCTYPE struts PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="demo" extends="struts-default">
<action name="hello" class="mypack.MyAction">
<result name="success">/hello.jsp</result>
</action>
</package></struts>

Second Java Annotation based configuration:-

Action.java

@Results({
@Result(name="input", value="/RegistrationSuccess.jsp" )
@Result(value="/RegistrationSuccess.jsp" )
})
public class Login implements Action {
public String execute() {
//Business logic for login
}
}

Previous Home Next