Files
struts2-demo/web/demo/hello/index.jsp
2026-03-18 18:12:20 +08:00

54 lines
2.4 KiB
Plaintext

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello Action Guide</title>
<style>
body { margin: 0; padding: 24px; font-family: "Aptos", "Segoe UI", sans-serif; background: linear-gradient(135deg, #1464c7, #3a8dff); }
.shell { max-width: 980px; margin: 0 auto; background: rgba(255,255,255,0.96); border-radius: 28px; padding: 28px; box-shadow: 0 24px 60px rgba(0,0,0,0.18); }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: #1464c7; font-weight: 800; }
h1, h2 { margin: 10px 0 12px; }
p, li { color: #53667d; line-height: 1.9; }
pre { background: #101827; color: #d9e7ff; padding: 18px; border-radius: 18px; overflow-x: auto; }
.links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn { display: inline-flex; padding: 10px 14px; border-radius: 999px; text-decoration: none; font-weight: 700; background: #e8f2ff; color: #1464c7; }
</style>
</head>
<body>
<div class="shell">
<div class="eyebrow">Guide</div>
<h1>Hello action walkthrough</h1>
<p>The hello demo is still the best first stop for explaining how Struts2 maps a request to an action and then routes to a JSP result.</p>
<h2>Flow</h2>
<ul>
<li>The browser requests <code>/hello</code> or <code>/hello?name=Team</code>.</li>
<li>Struts populates the <code>name</code> property on <code>HelloAction</code>.</li>
<li><code>execute()</code> builds a view message and returns <code>SUCCESS</code>.</li>
<li>The framework resolves the success result to <code>/hello.jsp</code>.</li>
</ul>
<h2>Minimal action shape</h2>
<pre>public class HelloAction extends ActionSupport {
private String name;
private String message;
public String execute() {
if (name == null || name.trim().isEmpty()) {
name = "World";
}
message = "Hello, " + name + "!";
return SUCCESS;
}
}</pre>
<div class="links">
<a class="btn" href="../../hello?name=Platform%20Team">Run hello action</a>
<a class="btn" href="../../index.jsp">Back to portal</a>
</div>
</div>
</body>
</html>