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 ...
随机推荐
- gdb带参调试
第一种方法:为程序传递参数5 root@guo-virtual-machine:~/debug# gdb --args factorial 5 第二种方法:为程序传递参数5 (gdb) run 5 方 ...
- (Bash博弈)51nod1067 Bash游戏 V2
1067 Bash游戏 V2 有一堆石子共有N个.A B两个人轮流拿,A先拿.每次只能拿1,3,4颗,拿到最后1颗石子的人获胜.假设A B都非常聪明,拿石子的过程中不会出现失误.给出N,问最后谁能赢得 ...
- springboot学习笔记-5 springboot整合shiro
shiro是一个权限框架,具体的使用可以查看其官网 http://shiro.apache.org/ 它提供了很方便的权限认证和登录的功能. 而springboot作为一个开源框架,必然提供了和sh ...
- git ssh https 踩坑记 ---- 域账号密码更新
前几天突然通知要更新公司的域账号密码,然后git pull就一直报 fatal: Authentication failed for 'https://git ... 很奇怪的是,有一个项目git p ...
- LightGBM 调参方法(具体操作)
sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003& ...
- 20165232 学习基础和c语言基础调查
做中学读后感 学习是要思考的,仅仅实践是不够的: 不光会动手,还要理解背后的原理 不光会用工具,还要理解支撑的理论 技能是分层次的: 一项技能的掌握程度分为:新手/高级初学者/合格者/精通/专家 对技 ...
- Event Recommendation Engine Challenge分步解析第四步
一.请知晓 本文是基于: Event Recommendation Engine Challenge分步解析第一步 Event Recommendation Engine Challenge分步解析第 ...
- 检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件时失 败,原因是出现以下错误: 80080005
.Net MVC项目,在下载一个Excel的时候总是报错. 解决办法: 在服务器中,运行dcomcnfg打开组件服务, 依次展开"组件服务"->"计算机" ...
- java Calendar 入门【转】
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar c = Calendar. ...
- golang json序列化
结构体序列化 func main() { var j = js{ Name: "zhangsan", Age: 16, Sal: 1500.3, Intro: "aiha ...