File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 2525import org .springframework .context .annotation .Bean ;
2626import org .springframework .stereotype .Controller ;
2727import 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
2933import javax .sql .DataSource ;
3034import 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 ()) {
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments