深入实践Spring Boot3.4.4 修改视图设计

简介:

3.4.4 修改视图设计

1.?修改对话框设计

在电影的主页中修改一部电影,首先打开一个修改电影的对话框,这个对话框的设计如代码清单3-22所示。其中通过“$.get”访问“./edit/{id}”取得数据和修改视图的HTML页面元素。

代码清单3-22 修改电影对话框js编码

function edit(id){

    $.get("./edit/"+id,{ts:new Date().getTime()},function(data){

        art.dialog({

            lock:true,

            opacity:0.3,

            title: "修改",

            width:'750px',

            height: 'auto',

            left: '50%', 

            top: '50%',

            content:data,

            esc: true,

            init: function(){

                artdialog = this;

            },

            close: function(){

                artdialog = null;

            }

        });

    });

}

2.?修改页面设计

修改电影视图的页面设计如代码清单3-23所示,其中剧照的下拉列表框中增加了“选中”的代码:th:selected="${movie.photo == f?ile}",即如果电影中的剧照与下拉框列表中的剧照相同,则选中它。

在修改界面上,还增加了“增加角色”和“选择演员”的编辑项。为了简化设计这里的角色名称我们也使用了预先定义的数据。

代码清单3-23 修改电影页面HTML编码

<link th:href="@{/styles/imageselect.css}" rel="stylesheet" type="text/css" />

<script th:src="@{/scripts/imageselect.js}"></script>

<script th:src="@{/scripts/movie/edit.js}"></script>

 

<form id="saveForm" method="post">

    <input type="hidden" name="id" id="id" th:value="${movie.id}"/>

<div class="addInfBtn" >

    <h3 class="itemTit"><span>编辑信息</span></h3>

    <table class="addNewInfList">

        <tr>

            <th>电影名称</th>

            <td width="240"><input class="inp-list w-200 clear-mr f-left" type=

"text" th:value="${movie.name}" id="name" name="name" maxlength="16" /></td>

            <th>电影剧照</th>

            <td width="240">

                <select name="photo" id="photo">

                    <option th:each="file:${files}"

                            th:value="${file}"

                            th:text="${file}"

                            th:selected="${movie.photo == file}">

                    </option>

                </select>

            </td>

        </tr>

 

        <tr>

            <th>出版日期</th>

            <td>

                <input  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"

type="text" class="inp-list w-200 clear-mr f-left" th:value="${movie.createDate} ? ${#dates.format(movie.createDate,'yyyy-MM-dd HH:mm:ss')} :''" id="createDate" name="createDate"/>

            </td>

 

        </tr>

        <tr>

            <th>增加角色</th>

            <td width="240">

                <select name="rolename" id="rolename">

                    <option value="">增加角色</option>

                    <option th:each="role:${rolelist}"

                            th:value="${role}"

                            th:text="${role}">

                    </option>

                </select>

            </td>

            <th>选择演员</th>

            <td width="240">

                <select name="actorid" id="actorid">

                    <option value="">选择演员</option>

                    <option th:each="actor:${actors}"

                            th:value="${actor.id}"

                            th:text="${actor.name}">

                    </option>

                </select>

            </td>

        </tr>

    </table>

 

    <div class="bottomBtnBox">

        <a class="btn-93X38 saveBtn" href="javascript:void(0)">确定</a>

        <a class="btn-93X38 backBtn" href="javascript:closeDialog(0)">返回</a>

    </div>

</div>

 

</form>

<script type="text/javascript">

    $(document).ready(function(){

        $('select[name=photo]').ImageSelect({dropdownWidth:425});

    });

</script>

3.?修改视图的设计效果

最终完成的修改电影视图的显示效果如图3-5所示。

 

图3-5 修改电影视图设计效果图

相关文章
|
1月前
|
缓存 Java API
【云原生】Spring Cloud Gateway的底层原理与实践方法探究
【云原生】Spring Cloud Gateway的底层原理与实践方法探究
|
2月前
|
安全 Java 数据库
后端进阶之路——万字总结Spring Security与数据库集成实践(五)
后端进阶之路——万字总结Spring Security与数据库集成实践(五)
|
3月前
|
Java 数据库连接 Spring
从零开始,探索Spring框架的魅力与实践
从零开始,探索Spring框架的魅力与实践
|
3月前
|
缓存 NoSQL Java
Spring Cache 缓存原理与 Redis 实践
Spring Cache 缓存原理与 Redis 实践
149 0
|
7月前
|
消息中间件 弹性计算 Java
Rocketmq-spring入门与实践
本场景带您体验如何在 Spring 生态中优雅地使用 Apache RocketMQ,感受最受欢迎业务开发框架与最受欢迎消息平台结合的魅力。
404 0
|
3月前
|
前端开发 安全 Java
Spring Boot项目中VO层设计:选择继承或组合的灵活实践
Spring Boot项目中VO层设计:选择继承或组合的灵活实践
102 0
|
10天前
|
监控 Java 数据库连接
Spring高手之路17——动态代理的艺术与实践
本文深入分析了JDK和CGLIB两种动态代理技术在Spring框架中的应用。讨论了动态代理的基础概念,通过实例展示了如何实现和应用这两种方法,并比较了它们的性能差异及适用场景。进一步,探讨了在动态代理中实现熔断限流和日志监控的策略,以及如何利用动态代理优化Spring应用的设计和功能。
25 6
Spring高手之路17——动态代理的艺术与实践
|
11天前
|
前端开发 Java Spring
数据之桥:深入Spring MVC中传递数据给视图的实用指南
数据之桥:深入Spring MVC中传递数据给视图的实用指南
29 3
|
3月前
|
存储 安全 Java
Spring Security中Token存储与会话管理:解析与实践
Spring Security中Token存储与会话管理:解析与实践
90 0
|
4月前
|
Java Spring
spring boot aop 实践---记录日志
spring boot aop 实践---记录日志
28 0