struts 2 first configuration
roject structure :
lib folders should have the following
commons-logging-1.0.4.jar commons-logging-api-1.1.jar freemaker-2.3.13.jar ognl-2.6.11.jar struts2-core-2.1.6.jar xwork-2.1.2.jar commons-fileload-1.2.1.jar struts-core-1.3.10.jar then remaining as per the developer needs.
first write the Action class HelloAction.java
eg
package com.struts.sample.action; import com.opensymphony.xwork2.ActionSupport; public class HelloAction extends ActionSupport{ String greetings = "test"; public String execute() throws Exception { if(greetings.equals("kumar")){ setGreetings("Hello World tested"); return SUCCESS; }else { setGreetings("Praveen"); return "Fail"; } } /** * @return the greetings */ public String getGreetings() { return greetings; } /** * @param greetings the greetings to set */ public void setGreetings(String greetings) { this.greetings = greetings; } }
2. create jsp files,
2.1 index.jsp
Struts 2 Example...