Skip to content

Commit ff47ec2

Browse files
author
Parvatam
committed
Demo
1 parent bc8201c commit ff47ec2

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
<artifactId>spring-boot-devtools</artifactId>
7777
<scope>runtime</scope>
7878
</dependency>
79+
80+
<dependency>
81+
<groupId>org.jscience</groupId>
82+
<artifactId>jscience</artifactId>
83+
<version>4.3.1</version>
84+
</dependency>
7985
</dependencies>
8086

8187
<build>

src/main/java/com/example/Main.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
import org.springframework.context.annotation.Bean;
2626
import org.springframework.stereotype.Controller;
2727
import org.springframework.web.bind.annotation.RequestMapping;
28+
import static javax.measure.unit.SI.KILOGRAM;
29+
import javax.measure.quantity.Mass;
30+
import org.jscience.physics.model.RelativisticModel;
31+
import org.jscience.physics.amount.Amount;
2832

2933
import javax.sql.DataSource;
3034
import java.sql.Connection;
@@ -74,6 +78,14 @@ String db(Map<String, Object> model) {
7478
}
7579
}
7680

81+
@RequestMapping("/hello")
82+
String hello(Map<String, Object> model) {
83+
RelativisticModel.select();
84+
Amount<Mass> m = Amount.valueOf("12 GeV").to(KILOGRAM);
85+
model.put("science", "E=mc^2: 12 GeV = " + m.toString());
86+
return "hello";
87+
}
88+
7789
@Bean
7890
public DataSource dataSource() throws SQLException {
7991
if (dbUrl == null || dbUrl.isEmpty()) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE html>
2+
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'hello')}">
3+
<body>
4+
<div class="container">
5+
<p th:text="${science}"/>
6+
</div>
7+
</body>
8+
</html>

0 commit comments

Comments
 (0)