Spring Boot ã§æ¸ç±ã®è²¸åºç¶æ³ç¢ºèªã»è²¸åºç³è«ãã Web ã¢ããªã±ã¼ã·ã§ã³ãä½ã ( ãã®ï¼ï¼ )( 貸åºå¸ææ¸ç± CSV ãã¡ã¤ã«ã¢ãããã¼ãç»é¢ã®ä½æï¼ )
æ¦è¦
- ä»åã®æé ã§ç¢ºèªã§ããã®ã¯ä»¥ä¸ã®å
容ã§ãã
- 貸åºå¸ææ¸ç± CSV ãã¡ã¤ã«ã¢ãããã¼ãç»é¢ã®ä½æ
- ç»é²æ©è½ãä½æãã¾ãã
- 貸åºå¸ææ¸ç± CSV ãã¡ã¤ã«ã¢ãããã¼ãç»é¢ã®ä½æ
åç §ãããµã¤ãã»æ¸ç±
- Spring AMQP x RabbitMQ
http://www.slideshare.net/keisuke69/spring-amqp-rabbitmq
ç®æ¬¡
æé
ç»é²æ©è½ã®ä½æ
ãç»é²ããã¿ã³ãã¯ãªãã¯ãããã RabbitMQ ã«è²¸åºç¶æ³åå¾ã¿ã¹ã¯ã¸ã®è²¸åºç¶æ³åå¾ä¾é ¼ã®ã¡ãã»ã¼ã¸ãéä¿¡ããå¾ãå®äºç»é¢ã表示ãã¾ãã
fileupload.html ã®ä¿®æ£
- src/main/resources/templates/booklist ã®ä¸ã® fileupload.html ã ãªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
RabbitMQ ã«è²¸åºç¶æ³åå¾ã¿ã¹ã¯ã¸ã®è²¸åºç¶æ³åå¾ä¾é ¼ã®ã¡ãã»ã¼ã¸ãéä¿¡ã§ããããã«ãã
-
以ä¸ã®ä»æ§ã§éä¿¡ã§ããããã«ãã¾ãã
- Queue ã®åå㯠InquiringStatusOfBookQueue ã«ãã¾ãã
- Queue ã«å ¥ããã¡ãã»ã¼ã¸ã®ãã©ã¼ããã㯠Java 以å¤ã§ã使ç¨ã§ãããã¨ãèæ ®ã㦠JSON ã«ãã¾ããSpring AMQP ã® MessageConverter 㯠JsonMessageConverter ( å¤ã org.codehaus.jackson.map.ObjectMapper ã使ç¨ããã¦ãã¾ã ) ã§ã¯ãªã Jackson2JsonMessageConverter ( æ°ãã com.fasterxml.jackson.databind.ObjectMapper ã使ç¨ããã¦ãã¾ã ) ã使ç¨ãã¾ãã
build.gradle ã ãªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
Gradle projects View ã®å·¦ä¸ã«ãããRefresh all Gradle projectsããã¿ã³ãã¯ãªãã¯ãã¦æ´æ°ãã¾ãã
src/main/resources ã®ä¸ã® application-develop.properties, application-unittest.properties, application-product.properties ã ãªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
ä»å使ç¨ãããã¥ã¼ãå®ç¾©ãã¾ããsrc/main/java/ksbysample/webapp/lending/config ã®ä¸ã® Constant.java ã ãªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
src/main/java/ksbysample/webapp/lending/config ã®ä¸ã® ApplicationConfig.java ã ãªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
src/main/java/ksbysample/webapp/lending/service ã®ä¸ã« queue ããã±ã¼ã¸ãä½æãã¾ãã
src/main/java/ksbysample/webapp/lending/service/queue ã®ä¸ã« InquiringStatusOfBookQueueMessage.java ãä½æãã¾ããä½æå¾ããªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
src/main/java/ksbysample/webapp/lending/service/queue ã®ä¸ã« InquiringStatusOfBookQueueService.java ãä½æãã¾ããä½æå¾ããªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
BooklistService ã¯ã©ã¹ã®ä¿®æ£
- src/main/java/ksbysample/webapp/lending/web/booklist ã®ä¸ã® BooklistService.java ã ãªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
BooklistController ã¯ã©ã¹ã®ä¿®æ£
src/main/java/ksbysample/webapp/lending/web/booklist ã®ä¸ã® RegisterBooklistForm.java ã ãªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
src/main/java/ksbysample/webapp/lending/web/booklist ã®ä¸ã® BooklistController.java ã ãªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
complete.html ã®ä¿®æ£
- src/main/resources/templates/booklist ã®ä¸ã® complete.html ã ãªã³ã¯å ã®å 容 ã«å¤æ´ãã¾ãã
åä½ç¢ºèª
åä½ç¢ºèªãã¾ãã
æåã« RabbitMQ ã«ãã¥ã¼ãä½æããã¦ããªããã¨ã確èªãã¾ããRabbitMQ ã®ãµã¼ãã¹ãèµ·åãã¦ããªãå ´åã«ã¯èµ·åãã¾ãã
Gradle projects View ãã bootRun ã¿ã¹ã¯ãå®è¡ã㦠Tomcat ãèµ·åãã¾ãã
http://localhost:15672/ ã¸ã¢ã¯ã»ã¹ããRabbitMQ ã®ç®¡çæ©è½ã®ãã°ã¤ã³ç»é¢ã表示ãããã guest/guest ã§ãã°ã¤ã³ãã¾ãã
ãããç»é¢ã表示ããã¦ãQueue ãã¾ã ä½æããã¦ããªããã¨ã確èªã§ãã¾ãã
http://localhost:8080/booklist ãããã¹ã.csv ãã¢ãããã¼ããã確èªç»é¢ã表示ãããå¾ãç»é²ããã¿ã³ãã¯ãªãã¯ãã¾ãã
貸åºç³è«ID ã表示ãããå®äºç»é¢ã表示ããã¾ãã
RabbitMQ ã®ç®¡çç»é¢ãæ´æ°ãã㨠Queue ãä½æããã¦ã¡ãã»ã¼ã¸ãèç©ããã¦ãããã¨ã確èªã§ãã¾ãã
ãQueues: 1ãã®ãã¿ã³ãã¯ãªãã¯ãã㨠Queue ä¸è¦§ã表示ãã㦠InquiringStatusOfBookQueue ãä½æããã¦ãããã¨ã確èªã§ãã¾ãã
ãã¥ã¼åã®ãInquiringStatusOfBookQueueããªã³ã¯ãã¯ãªãã¯ã㦠Queue ã®ç»é¢ã«é·ç§»ããå¾ããGet messagesãã®ã¨ããã«ãããGet Message(s)ããã¿ã³ãæ¼ãã¦èç©ããã¦ããã¡ãã»ã¼ã¸ã®å 容ã確èªãã¾ããå®äºç»é¢ã«è¡¨ç¤ºããã貸åºç³è«ID ã®ã¡ãã»ã¼ã¸ãèç©ããã¦ãããã¨ã確èªã§ãã¾ãã
ãRequeueãã®é¸æã No ã«å¤æ´ãã¦ãããGet Message(s)ããã¿ã³ãæ¼ãã¦ã¡ãã»ã¼ã¸ãåé¤ãã¾ãã
Ctrl+F2 ãæ¼ã㦠Tomcat ãåæ¢ãã¾ãã
ä¸æ¦ commit ãã¾ãã
次åã¯ããã
ãã¹ããä½æãã¾ãã
ã½ã¼ã¹ã³ã¼ã
fileupload.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <title>貸åºå¸ææ¸ç± CSV ãã¡ã¤ã«ã¢ãããã¼ã</title> <!-- Tell the browser to be responsive to screen width --> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/> <link th:replace="common/head-cssjs"/> <style type="text/css"> <!-- .box-body.no-padding { padding-bottom: 10px !important; } --> </style> </head> <!-- ADD THE CLASS layout-top-nav TO REMOVE THE SIDEBAR. --> <body class="skin-blue layout-top-nav"> <div class="wrapper"> <!-- Main Header --> <div th:replace="common/mainparts :: main-header"></div> <!-- Full Width Column --> <div class="content-wrapper"> <div class="container"> <!-- Content Header (Page header) --> <section class="content-header"> <h1>貸åºå¸ææ¸ç± CSV ãã¡ã¤ã«ã¢ãããã¼ã</h1> </section> <!-- Main content --> <section class="content"> <div class="row"> <div class="col-xs-12"> <div class="box"> <div class="box-body no-padding"> <form id="registerBooklistForm" method="post" action="/booklist/register" th:action="@{/booklist/register}" th:object="${registerBooklistForm}"> <table class="table table-hover"> <colgroup> <col width="5%"/> <col width="35%"/> <col width="60%"/> </colgroup> <thead class="bg-purple"> <tr> <th>No.</th> <th>ISBN</th> <th>æ¸å</th> </tr> </thead> <tbody class="jp-gothic"> <tr th:each="row, iterStat : *{registerBooklistRowList}"> <th th:text="${iterStat.count}">1</th> <th th:text="${row.isbn}">978-1-4302-5908-4</th> <th th:text="${row.bookName}">Spring Recipes</th> </tr> </tbody> </table> <input type="hidden" name="lendingAppId" th:value="*{lendingAppId}"/> <div class="text-center"> <button class="btn bg-blue js-btn-register"><i class="fa fa-save"></i>ãç»é²</button> <button class="btn bg-orange js-btn-backindex"><i class="fa fa-undo"></i>ããã¡ã¤ã«ãã¢ãããã¼ããç´ã</button> </div> </form> </div> </div> </div> </div> </section> <!-- /.content --> </div> <!-- /.container --> </div> </div> <!-- ./wrapper --> <script th:replace="common/bottom-js"></script> <script type="text/javascript"> <!-- $(document).ready(function() { $(".js-btn-register").click(function(){ $("#registerBooklistForm").submit(); return false; }); $(".js-btn-backindex").click(function(){ location.href = "/booklist"; return false; }); }); --> </script> </body> </html>
<input type="hidden" th:value="*{lendingAppId}"/>
â<input type="hidden" name="lendingAppId" th:value="*{lendingAppId}"/>
ã¸å¤æ´ãã¾ãã
build.gradle
dependencies { def jdbcDriver = "org.postgresql:postgresql:9.4-1203-jdbc41" // spring-boot-gradle-plugin ã«ãããã¼ã¸ã§ã³çªå·ãèªåã§è¨å®ããããã® // Appendix E. Dependency versions ( http://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html ) åç § compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.boot:spring-boot-starter-thymeleaf") compile("org.thymeleaf.extras:thymeleaf-extras-springsecurity3") compile("org.springframework.boot:spring-boot-starter-data-jpa") compile("org.springframework.boot:spring-boot-starter-velocity") compile("org.springframework.boot:spring-boot-starter-mail") compile("org.springframework.boot:spring-boot-starter-security") compile("org.springframework.boot:spring-boot-starter-redis") compile("org.springframework.boot:spring-boot-starter-amqp") compile("org.codehaus.janino:janino") testCompile("org.springframework.boot:spring-boot-starter-test") // (ãããã) gradle ã§ãã¹ããå®è¡ããå ´åã« spring-security-test-4.0.2.RELEASE.jar ãã classpath ã«æå®ããã // ãã¹ãã失æããããã3.2.8.RELEASE ãæè¨ãã¦ãã testCompile("org.springframework.security:spring-security-core:3.2.8.RELEASE") testCompile("org.springframework.security:spring-security-web:3.2.8.RELEASE") // (ããã¾ã§) ------------------------------------------------------------------------------------------------------ testCompile("org.springframework.security:spring-security-test:4.0.2.RELEASE") testCompile("org.yaml:snakeyaml") // spring-boot-gradle-plugin ã«ãããã¼ã¸ã§ã³çªå·ãèªåã§è¨å®ãããªããã® compile("${jdbcDriver}") compile("org.seasar.doma:doma:2.4.1") compile("org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16") compile("org.apache.commons:commons-lang3:3.4") compile("org.projectlombok:lombok:1.16.4") compile("com.google.guava:guava:18.0") compile("org.springframework.session:spring-session:1.0.1.RELEASE") compile("org.simpleframework:simple-xml:2.7.1") compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.6.2") compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.6.2") compile("com.univocity:univocity-parsers:1.5.6") testCompile("org.dbunit:dbunit:2.5.1") testCompile("com.icegreen:greenmail:1.4.1") testCompile("org.assertj:assertj-core:3.2.0") testCompile("com.jayway.jsonpath:json-path:2.0.0") testCompile("org.jmockit:jmockit:1.19") // for Doma-Gen domaGenRuntime("org.seasar.doma:doma-gen:2.4.1") domaGenRuntime("${jdbcDriver}") }
compile("org.springframework.boot:spring-boot-starter-amqp")
ã追å ããã
application-develop.properties, application-unittest.properties, application-product.properties
â application-develop.properties
spring.datasource.url=jdbc:log4jdbc:postgresql://localhost/ksbylending spring.datasource.username=ksbylending_user spring.datasource.password=xxxxxxxx spring.datasource.driverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy spring.mail.host=localhost spring.mail.port=25 spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 spring.redis.sentinel.master=mymaster spring.redis.sentinel.nodes=localhost:6381,localhost:6382,localhost:6383 spring.messages.cache-seconds=0 spring.thymeleaf.cache=false spring.velocity.cache=false
- spring.rabbitmq.host, spring.rabbitmq.port ã追å ãã¾ãã
â application-unittest.properties
spring.datasource.url=jdbc:postgresql://localhost/ksbylending spring.datasource.username=ksbylending_user spring.datasource.password=xxxxxxxx spring.datasource.driverClassName=org.postgresql.Driver spring.mail.host=localhost spring.mail.port=25 spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 spring.redis.sentinel.master=mymaster spring.redis.sentinel.nodes=localhost:6381,localhost:6382,localhost:6383 spring.thymeleaf.cache=true
- spring.rabbitmq.host, spring.rabbitmq.port ã追å ãã¾ãã
â application-product.properties
server.tomcat.basedir=C:/webapps/ksbysample-webapp-lending spring.datasource.url=jdbc:postgresql://localhost/ksbylending spring.datasource.username=ksbylending_user spring.datasource.password=xxxxxxxx spring.datasource.driverClassName=org.postgresql.Driver spring.mail.host=localhost spring.mail.port=25 spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 spring.redis.sentinel.master=mymaster spring.redis.sentinel.nodes=localhost:6381,localhost:6382,localhost:6383 spring.thymeleaf.cache=true
- spring.rabbitmq.host, spring.rabbitmq.port ã追å ãã¾ãã
Constant.java
package ksbysample.webapp.lending.config; public class Constant { /* * RabbitMQ Queueä¸è¦§ */ public static final String QUEUE_NAME_INQUIRING_STATUSOFBOOK = "InquiringStatusOfBookQueue"; /* * URLä¸è¦§ */ public static final String URL_ADMIN_LIBRARY = "/admin/library"; /* * ãã°ã¤ã³å¾ãã¼ã¸ã®URL */ public static final String URL_AFTER_LOGIN_FOR_ROLE_ADMIN = URL_ADMIN_LIBRARY; }
- QUEUE_NAME_INQUIRING_STATUSOFBOOK ã追å ãã¾ãã
ApplicationConfig.java
package ksbysample.webapp.lending.config; import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class ApplicationConfig { @Autowired private ConnectionFactory connectionFactory; @Bean public Queue inquiringStatusOfBookQueue() { return new Queue(Constant.QUEUE_NAME_INQUIRING_STATUSOFBOOK, false); } @Bean public RabbitTemplate rabbitTemplate() { RabbitTemplate rabbitTemplate = new RabbitTemplate(this.connectionFactory); rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter()); return rabbitTemplate; } }
private ConnectionFactory connectionFactory;
ã追å ãã¾ãã- queueInquiringStatusOfBook Bean ã追å ãã¾ãã
- rabbitTemplate Bean ã追å ãã¦ãä¸ã§ Jackson2JsonMessageConverter ãã»ãããã¾ãã
InquiringStatusOfBookQueueMessage.java
package ksbysample.webapp.lending.service.queue; import lombok.Data; @Data public class InquiringStatusOfBookQueueMessage { private Long lendingAppId; }
InquiringStatusOfBookQueueService.java
package ksbysample.webapp.lending.service.queue; import ksbysample.webapp.lending.config.Constant; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class InquiringStatusOfBookQueueService { @Autowired private RabbitTemplate rabbitTemplate; public void sendMessage(Long lendingAppId) { InquiringStatusOfBookQueueMessage message = new InquiringStatusOfBookQueueMessage(); message.setLendingAppId(lendingAppId); rabbitTemplate.convertAndSend(Constant.QUEUE_NAME_INQUIRING_STATUSOFBOOK, message); } }
BooklistService.java
package ksbysample.webapp.lending.web.booklist; import ksbysample.webapp.lending.dao.LendingAppDao; import ksbysample.webapp.lending.dao.LendingBookDao; import ksbysample.webapp.lending.entity.LendingApp; import ksbysample.webapp.lending.entity.LendingBook; import ksbysample.webapp.lending.security.LendingUserDetails; import ksbysample.webapp.lending.service.file.BooklistCSVRecord; import ksbysample.webapp.lending.service.file.BooklistCsvFileService; import ksbysample.webapp.lending.service.queue.InquiringStatusOfBookQueueService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import java.util.List; import static ksbysample.webapp.lending.values.LendingAppStatusValues.TENPORARY_SAVE; @Service public class BooklistService { @Autowired private BooklistCsvFileService booklistCsvFileService; @Autowired private LendingAppDao lendingAppDao; @Autowired private LendingBookDao lendingBookDao; @Autowired private InquiringStatusOfBookQueueService inquiringStatusOfBookQueueService; public Long temporarySaveBookListCsvFile(UploadBooklistForm uploadBooklistForm) { // ã¢ãããã¼ããããCSVãã¡ã¤ã«ã®ãã¼ã¿ã List ã«å¤æãã List<BooklistCSVRecord> booklistCSVRecordList = booklistCsvFileService.convertFileToList(uploadBooklistForm.getFileupload()); // ç¾å¨ãã°ã¤ã³ãã¦ããã¦ã¼ã¶æ å ±ãåå¾ãã Authentication auth = SecurityContextHolder.getContext().getAuthentication(); LendingUserDetails lendingUserDetails = (LendingUserDetails) auth.getPrincipal(); // lending_app ãã¼ãã«ã«ãã¼ã¿ãä¿åãã LendingApp lendingApp = new LendingApp(); lendingApp.setStatus(TENPORARY_SAVE.getValue()); lendingApp.setLendingUserId(lendingUserDetails.getUserId()); lendingAppDao.insert(lendingApp); // lending_book ãã¼ãã«ã«ãã¼ã¿ãä¿åãã LendingBook lendingBook; for (BooklistCSVRecord booklistCSVRecord : booklistCSVRecordList) { lendingBook = new LendingBook(); BeanUtils.copyProperties(booklistCSVRecord, lendingBook); lendingBook.setLendingAppId(lendingApp.getLendingAppId()); lendingBookDao.insert(lendingBook); } return lendingApp.getLendingAppId(); } public List<LendingBook> getLendingBookList(Long lendingAppId) { List<LendingBook> lendingBookList = lendingBookDao.selectByLendingAppId(lendingAppId); return lendingBookList; } public void updateLendingAppStatusToPending(RegisterBooklistForm registerBooklistForm) { inquiringStatusOfBookQueueService.sendMessage(registerBooklistForm.getLendingAppId()); } }
- updateLendingAppStatusToPending ã¡ã½ããã追å ãã¾ãã
RegisterBooklistForm.java
package ksbysample.webapp.lending.web.booklist; import ksbysample.webapp.lending.entity.LendingBook; import lombok.Data; import org.springframework.beans.BeanUtils; import java.util.List; import java.util.stream.Collector; import java.util.stream.Collectors; @Data public class RegisterBooklistForm { private List<RegisterBooklistRow> registerBooklistRowList; private Long lendingAppId; public RegisterBooklistForm() { } public RegisterBooklistForm(List<LendingBook> lendingBookList, Long lendingAppId) { this.registerBooklistRowList = lendingBookList.stream() .map(RegisterBooklistRow::new) .collect(Collectors.toList()); this.lendingAppId = lendingAppId; } @Data public class RegisterBooklistRow { private String isbn; private String bookName; public RegisterBooklistRow(LendingBook lendingBook) { BeanUtils.copyProperties(lendingBook, this); } } }
- å¼æ°ã®ãªãã³ã³ã¹ãã©ã¯ã¿
RegisterBooklistForm()
ã追å ãã¾ãã
BooklistController.java
package ksbysample.webapp.lending.web.booklist; import ksbysample.webapp.lending.entity.LendingBook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import java.util.List; @Controller @RequestMapping("/booklist") public class BooklistController { @Autowired private UploadBooklistFormValidator uploadBooklistFormValidator; @Autowired private BooklistService booklistService; @InitBinder("uploadBooklistForm") public void initBinder(WebDataBinder binder) { binder.addValidators(uploadBooklistFormValidator); } @RequestMapping public String index(UploadBooklistForm uploadBooklistForm) { return "booklist/booklist"; } @RequestMapping("/fileupload") public String fileupload(@Validated UploadBooklistForm uploadBooklistForm , BindingResult bindingResult , Model model) { if (bindingResult.hasErrors()) { return "booklist/booklist"; } // ã¢ãããã¼ããããCSVãã¡ã¤ã«ã®ãã¼ã¿ãDBã«ä¿åãã Long lendingAppId = booklistService.temporarySaveBookListCsvFile(uploadBooklistForm); // 確èªç»é¢ã«è¡¨ç¤ºãããã¼ã¿ãåå¾ãã List<LendingBook> lendingBookList = booklistService.getLendingBookList(lendingAppId); RegisterBooklistForm registerBooklistForm = new RegisterBooklistForm(lendingBookList, lendingAppId); model.addAttribute("registerBooklistForm", registerBooklistForm); return "booklist/fileupload"; } @RequestMapping("/register") public String register(RegisterBooklistForm registerBooklistForm , RedirectAttributes redirectAttributes) { booklistService.updateLendingAppStatusToPending(registerBooklistForm); redirectAttributes.addFlashAttribute("lendingAppId", registerBooklistForm.getLendingAppId()); return "redirect:/booklist/complete"; } @RequestMapping("/complete") public String complete() { return "booklist/complete"; } }
- register ã¡ã½ããã®ä»¥ä¸ã®ç¹ãå¤æ´ãã¾ãã
booklistService.updateLendingAppStatusToPending(registerBooklistForm);
ã追å ãã¾ãã- ãªãã¤ã¬ã¯ãå
ã®å®äºç»é¢ã§ lending_app.lending_app_id ã®å¤ã表示ãããããã«ãã¡ã½ããã®å¼æ°ã«
RedirectAttributes redirectAttributes
ã追å ããã¡ã½ããå ã®å¦çã«redirectAttributes.addFlashAttribute("lendingAppId", registerBooklistForm.getLendingAppId());
ã追å ãã¾ãã
complete.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <title>貸åºå¸ææ¸ç± CSV ãã¡ã¤ã«ã¢ãããã¼ã</title> <!-- Tell the browser to be responsive to screen width --> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/> <link th:replace="common/head-cssjs"/> <style type="text/css"> <!-- .lending-oneline-msgbox { height: 70px; padding-top: 10px; } --> </style> </head> <!-- ADD THE CLASS layout-top-nav TO REMOVE THE SIDEBAR. --> <body class="skin-blue layout-top-nav"> <div class="wrapper"> <!-- Main Header --> <div th:replace="common/mainparts :: main-header"></div> <!-- Full Width Column --> <div class="content-wrapper"> <div class="container"> <!-- Content Header (Page header) --> <section class="content-header"> <h1>貸åºå¸ææ¸ç± CSV ãã¡ã¤ã«ã¢ãããã¼ã</h1> </section> <!-- Main content --> <section class="content"> <div class="row"> <div class="col-xs-12"> <div class="lending-oneline-msgbox"> <p><span class="text-bold">貸åºç³è«IDï¼<span th:text="${lendingAppId}">1</span></span><br/> ã§è²¸åºå¸ææ¸ç±ãç»é²ãã¾ãããé¸æä¸ã®å³æ¸é¤¨ã«èµæ¸ã®æç¡ã¨è²¸åºç¶æ³ãåãåããã¾ãã</p> </div> <button class="btn bg-blue js-btn-moveindex"><i class="fa fa-file-text"></i>ãå¥ã®è²¸åºå¸ææ¸ç±ãç»é²ãã</button> </div> </div> </section> <!-- /.content --> </div> <!-- /.container --> </div> </div> <!-- ./wrapper --> <script th:replace="common/bottom-js"></script> <script type="text/javascript"> <!-- $(document).ready(function() { $(".js-btn-moveindex").click(function(){ location.href = "/booklist"; return false; }); }); --> </script> </body> </html>
.lending-oneline-msgbox
å ã§height: 50px;
âheight: 70px;
ã¸å¤æ´ãã¾ãã<span class="text-bold">貸åºç³è«IDï¼<span th:text="${lendingAppId}">1</span></span><br/>
ã追å ãã¾ãã
å±¥æ´
2015/10/04
åççºè¡ã