这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.baeldung.boot.jsp.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/course")
public class WelcomeController {

@GetMapping("/welcome")
public String greetingAndWelcome() {
return "course/welcome";
}

@GetMapping("/welcome-usebean")
public String greetingAndWelcomeUseBean() {
return "course/welcome-usebean";
}

@GetMapping("/welcome-by-javabean")
public String greetingAndWelcomeByJavaBean() {
return "course/welcome-by-javabean";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.baeldung.boot.jsp.coursewelcome;

public class CourseWelcome {

public String greeting(String username) {
return String.format("Hi %s, how are you doing?", username);
}

public static String staticWelcome(String courseName) {
return String.format("Welcome to Baeldung's %s course", courseName);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.baeldung.boot.jsp.coursewelcome;

public class CourseWelcomeBean {

private String username;
private String courseName;

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getCourseName() {
return courseName;
}

public void setCourseName(String courseName) {
this.courseName = courseName;
}

public String greetingUser() {
return String.format("Hi %s, how do you do?", username);
}

public String welcomeMsg() {
return String.format("Welcome to Baeldung's %s course!", courseName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Welcome to Course</title>
</head>
<body>
<p>Using jsp:useBean action with a JavaBean</p>
<jsp:useBean id="courseWelcomeBean" class="com.baeldung.boot.jsp.coursewelcome.CourseWelcomeBean"/>
<jsp:setProperty name="courseWelcomeBean" property="username" value="Eric"/>
<jsp:setProperty name="courseWelcomeBean" property="courseName" value="Spring Security"/>
<div><%= courseWelcomeBean.greetingUser()%></div>
<div><%= courseWelcomeBean.welcomeMsg()%></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<title>Welcome to Course</title>
</head>
<body>
<p>Using jsp:useBean action</p>
<jsp:useBean id="welcomeBean" class="com.baeldung.boot.jsp.coursewelcome.CourseWelcome"/>
<div>
<%= welcomeBean.greeting("Kevin")%>
</div>
<div>
<%= com.baeldung.boot.jsp.coursewelcome.CourseWelcome.staticWelcome("Java Collections")%>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.baeldung.boot.jsp.coursewelcome.CourseWelcome" %>
<html>
<head>
<title>Welcome to Course</title>
</head>
<body>
<%
CourseWelcome courseWelcomeObj = new CourseWelcome();
%>
<div><%= courseWelcomeObj.greeting("Kai")%></div>
<div><%= CourseWelcome.staticWelcome("Spring Boot")%></div>
</body>
</html>