thymeleaf简单语法、js的请求

柔情痞子 提交于 2020-03-17 22:47:45

thymeleaf简单语法

参考博客: https://www.cnblogs.com/msi-chen/p/10974009.html
参考博客:https://segmentfault.com/a/1190000017563310#item-1-9
js的请求:https://blog.csdn.net/weixin_33734785/article/details/92405678

<!--                    评论编辑区-->
            <div class="ui form">
                <div class="field">
                    <textarea id="content" name="content" placeholder="请输入评论信息..."></textarea>
                </div>

                <div class="fields">
                    <div class="field  m-margin-bottom-small m-mobile-wide">
                        <button class="ui teal button m-mobile-wide" id="submitContent"><i class="edit icon"></i>发布</button>
                    </div>
                </div>
            </div>
<!--                    评论编辑区-->
<script>
    $('#submitContent').click(function () {
        var uid = [[${uid}]];
        var content = $('#content').val();
        var data = {
            "uid": uid,
            "content": content
        };

        console.log(content)
        $.ajax({
            url : "http://localhost:8080/comment",
            type : "POST",
            headers:{"Content-Type":"application/json;charset=UTF-8"},
            data: JSON.stringify(data),
            success : function(data){
                 alert("评论完成!");
            },
            error : function(data){
                alert("评论失败!");
            },
            finally: function (data) {
                alert("是否提交!")
            }
        })

    })

</script>
    @RequestMapping(value = "/comment", method = RequestMethod.POST)
    public String comment(@RequestBody Abc abc, Model model) {
        UserBlogCommentInfo userBlogCommentInfo = userService.selectUserInfoByUid(abc.getUid());
        System.out.println(userBlogCommentInfo.getAvatar());
        System.out.println(userBlogCommentInfo.getUserName());
        System.out.println(abc.getContent());
        return "blog";
    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!