Thymeleaf在前台下拉列表获取后台传的值
Thymeleaf在前台下拉列表获取后台传的值
后台添加代码:

/**
* 新增机构
*/
@GetMapping("/add")
public String add(ModelMap mmap)
{
List<Scholar> scholars = scholarService.selectScholarListName();
mmap.put("scholars",scholars);
return "module/institution/add";
}

后台修改代码:

/**
* 修改机构
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") String id, ModelMap mmap)
{
Institution institution = institutionService.selectInstitutionById(id);
List<Scholar> scholars = scholarService.selectScholarListName();
mmap.put("scholars",scholars);
mmap.put("institution", institution);
return "module/institution/edit";
}

前台代码添加:

<div class="form-group">
<label class="col-sm-3 control-label">主要研究人员:</label>
<div class="col-sm-8" >
<!--<input id="majorResearcher" name="majorResearcher" class="form-control" type="hidden">-->
<!--<select name="title" id="title" class="form-control m-b">
<option th:each="scholars : ${scholars.title}" th:text="${scholars.title}" th:value="${scholars.title}" ></option>
</select>-->
<select class="form-control" name="majorResearcher">
<option value=""> -- 主要研究人员 -- </option>
<option th:each="scholars:${scholars}" th:value="${scholars.title}" th:text="${scholars.title}"></option>
</select> </div>
</div>

前台代码回显:

<div class="form-group">
<label class="col-sm-3 control-label">主要研究人员:</label>
<div class="col-sm-8">
<!-- <input id="majorResearcher" name="majorResearcher" th:field="*{majorResearcher}" class="form-control" type="text" >-->
<select class="form-control" name="majorResearcher">
<option value=""> -- 主要研究人员 -- </option>
<option th:each="scholars:${scholars}" th:value="${scholars.title}" th:text="${scholars.title}" th:field="*{majorResearcher}"></option>
</select>
</div>
</div>

前台页面添加效果:

前台页面回显效果:

前台页面的效果:

参考:https://www.cnblogs.com/zhukaixin/p/10488763.html
Thymeleaf在前台下拉列表获取后台传的值的更多相关文章
- js前台中获取后台传的值
后台controller String ifOffice = "yes";req.setAttribute("ifOffice", ifOffice); 前台j ...
- thymeleaf 模板使用 之 前台界面获取后台属性值
使用Thymeleaf模板时,如果需要在js中获取后台传值,那么需要用内联JS写法获取 [姿势很重要] 一.后台通过Model的addAttribute方法向前台传值 1.js获取后台属性值(--内联 ...
- js获取后台传给前台的值
1.后台传给前台的方法 String rulemodeid=req.getParameter("rulemodeid"); req.setAttribute("rulem ...
- Thymleaf js直接获取后台传过来的对象或者对象的属性以及map
简单说明:第一次接触thymleaf模板,对于thymleaf在js中如何获取后台传递过来的值,真的挺简单的,记住就行了 代码: 后台代码: //传递一个org对象给jspublic String t ...
- jsp页面获取后台传过来的list集合的长度
在jsp页面导入函数标签库: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"% ...
- 关于如何在highchart上获取后台返回的值一些问题。
项目开发过程中有用到highchart图表进行项目的开发.一个比较常规的需求就是通过点击图表上的模块进行明细的查看. 1.比如坐标一月.二月.三月.四月.....有对应的值01,02,03,04... ...
- 动态获取后台传过来的值作为select选项
问题描述:点击左侧菜单项,进入对应的具体页面a.html,页面上方有个select框,点击框后,会浮现选择项. 解决思路:对左侧菜单项添加一个onclick事件,进入后台做具体的查询,将查询到的lis ...
- 前台freemark获取后台的值
1.后台代码: ModelAndView mv = new ModelAndView("log/logList.ftl"); String info="abc" ...
- 前台页面获取servlet传过来的数据
servlet中的代码: public void doGet(HttpServletRequest request, HttpServletResponse response) throws Serv ...
随机推荐
- 5.1、按键SW1控制LED1亮灭
从图中可以看出,P1_2引脚可以感知SW1的状态,SW1未按下P1_2=1高电平,按下后P1_2=0接地. 注意:P1_2引脚只是感知SW1,不影响SW1. #include "ioCC25 ...
- HTML学习笔记Day5
一.CSS属性 1.文本溢出是否“...”显示属性:text-overflow:clip(不显示省略标记)/ellipsis(文本溢出时“...”显示) 定义此属性有四个必要条件:1)须有容器宽度:w ...
- 100.Same Tree(E)
100. same tree 100. Same Tree Given two binary trees, write a function to check if they are the same ...
- (Set){A} + {B} hdu1412
{A} + {B} 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1412 Problem Description 给你两个集合,要求{A} + {B} ...
- 爬虫之requests请求库高级应用
1.SSL Cert Verification #证书验证(大部分网站都是https) import requests respone=requests.get('https://www.12306. ...
- Presto JVM.config
Presto 如果启动时候 指定 CMS,那么 launcher run 会提示 G1 回收算法是 推荐的垃圾回收算法,针对 Presto 大内存 回收,G1 暂时 应该是最稳妥的选择,调整之后大约如 ...
- R语言学习网址
1. https://www.r-bloggers.com/ 2. https://www.kaggle.com/datasets 3. RStudio download: https://www.r ...
- Systemd 添加自定义服务(开机自启动)
Systemd 简介:https://fedoraproject.org/wiki/Systemd/zh-cn 一.service unit 常用命令,以 mysql 服务为例 # 开机启动 syst ...
- 鼠标右键Table的td弹出多级菜单,双击td编辑
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C ...
- Docker 从入门到放弃(三)镜像使用
当运行容器时,使用的镜像如果在本地中不存在,docker 就会自动从 docker 镜像仓库中下载,默认是从 Docker Hub 公共镜像源下载. 下面我们来学习: 1.管理和使用本地 Docker ...