Files
struts2-demo/web/WEB-INF/classes/com/demo/action/HelloAction.java
2026-03-18 18:12:20 +08:00

52 lines
1.2 KiB
Java

package com.demo.action;
import com.opensymphony.xwork2.ActionSupport;
public class HelloAction extends ActionSupport {
private String name;
private String message;
private String tip;
private String nextStep;
private String requestSample;
@Override
public String execute() {
if (name == null || name.trim().isEmpty()) {
name = "World";
} else {
name = name.trim();
}
message = "Hello, " + name + "! Welcome to the Struts2 demo lab.";
tip = "Struts2 injected the request parameter into the action property before execute() ran.";
nextStep = "Try the login flow or open the demo catalog to compare different action patterns.";
requestSample = "/hello?name=Platform%20Team";
return SUCCESS;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMessage() {
return message;
}
public String getTip() {
return tip;
}
public String getNextStep() {
return nextStep;
}
public String getRequestSample() {
return requestSample;
}
}