10.新增博客功能-結束語---《Beetl視頻課程》

本期視頻實現發佈新博客功能

一起學beetl目錄:https://my.oschina.net/u/1590490?tab=newest&catalogId=6214598

作者:GK


教程進入了尾聲,該講的知識點基本講到了,本節課不會講新的知識點。

今天來實現最後一個功能:發佈博客。

新建一個發佈頁面 create.html

<%
layout("/common/layout.html",{title:"新建博客",notShow:true}){
%>

<div class="widewrapper main">
        <div class="container">
            <div class="row">
                <div class="col-md-6 col-md-offset-3 clean-superblock" id="contact">
                    <h2>Contact</h2>
                    
                    <form action="${ctxPath}/saveBlog" method="post" accept-charset="utf-8" class="contact-form">
                        <input type="text" name="title" id="contact-name" placeholder="title" class="form-control input-lg">
                        <input type="text" name="category" id="contact-email" placeholder="category" class="form-control input-lg">
                        <input type="text" name="img"  placeholder="圖片地址" class="form-control input-lg">

                        <textarea rows="10" name="content" id="contact-body" placeholder="Your Content" class="form-control input-lg"></textarea>

                        <div class="buttons clearfix">
                            <button type="submit" class="btn btn-xlarge btn-clean-one">Submit</button>
                        </div>                    
                    </form>
                </div>
            </div>        
        </div>
    </div>
<%}%>

在後臺增加兩個請求:

    @GetMapping("/createBlog")
    public String createBlog(HttpServletRequest request) {
        return "create.html";
    }

    @PostMapping("/saveBlog")
    public String saveBlog(
            Blog blog,
            HttpServletRequest request) {
        blogService.saveBlog(blog);
        return "redirect:/";
    }

訪問 localhost:8080/createBlog進行博客新增。

到這一節該講的知識點都講完了,只要大家熟練的使用前幾節講的知識點,能夠應付大部分場景了。

我們這一套《一起學Beetl》視頻課程也結束了。

博客還有刪除、修改,功能沒有實現,還有更多更加豐富的功能可以實現,這些都留給大家,當做課後作業,如果有同學能提交PR更好不過了。

有人說爲什麼這麼簡單的知識點講的這麼慢,而且磕磕絆絆。

做這個視頻最初的想法是,帶着錯誤和大家一起去開發,不至於讓新手在遇到錯誤時,束手無策,所以會有一些磕磕絆絆。

希望大家能自己去探索和發現Beetl更多高級功能,真的很強大!加油!

項目git地址:https://gitee.com/gavink/beetl-blog

視頻地址:下載下來會更清晰,視頻比較長,可使用倍速看

百度網盤下載: https://pan.baidu.com/s/1LyxAxlKpVXgVjwSXIbzBuA 提取碼: 68im

在線播放地址:bilibili (可以調節清晰度): https://www.bilibili.com/video/av36278644/?p=10

博客目錄:https://my.oschina.net/u/1590490?tab=newest&catalogId=6214598

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章