Класс My Action приведен ниже:
Код: Выделить всё
package manning.chapterTwo;
import org.apache.struts2.config.Result;
import com.opensymphony.xwork2.ActionSupport;
@Result(name="SUCCESS", value="/chapterTwo/HelloWorld.jsp" )
public class AnnotatedHelloWorldAction extends ActionSupport{
private static final long serialVersionUID = 1L;
private static final String GREETING = "Hello ";
public String execute() {
setCustomGreeting( GREETING + getName() );
return "SUCCESS";
}
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private String customGreeting;
public String getCustomGreeting()
{
return customGreeting;
}
public void setCustomGreeting( String customGreeting ){
this.customGreeting = customGreeting;
}
}
Код: Выделить всё
NameCollector.jspКод: Выделить всё
Name Collector
[h4]Enter your name so that we can customize a greeting just for you![/h4]
Код: Выделить всё
HelloWorld
Custom Greeting Page
[h4][/h4]
Код: Выделить всё
web.xmlКод: Выделить всё
Struts2HelloWorldXML
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
actionPackages
manning
struts2
/*
Подробнее здесь: https://stackoverflow.com/questions/183 ... n-struts-2
Мобильная версия