thymeleaf if多条件判断
只能用一个th:if,多个th:if会报错,
亲测用and 连接2个判断,&&不行
th:if="(${t.pid}==${s.id}) and ${t.recycle!=1}"
<select id="operator" name="productCode" class="form-control m-b"
th:with="type=${@dict.getType('sys_product_code')}"
onchange="selectOperator();" required>
<option value="">所有</option>
<option th:each="dict : ${type}" th:if="${dict.dictValue !='MOBILE'} and ${dict.dictValue !='UNICOM'} and ${dict.dictValue !='TELECOM'} " th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
表单中只读表示Readonly和Disabled区别
一句话:表单元素在使用了disabled后,当我们将表单以POST或GET的方式提交的话,这个元素的值无法被传递出去,而readonly不存在这个问题。
html 元素隐藏
hidden
jquery 获取select选定的值与文本
function selectOperator() {
var v_name = $("#productCode option:selected").text()
console.log("===" + v_name)
$("#productName").attr("value", v_name);
}
jquery对所有input type=text的控件赋值实现方法
function resetData() {
$("input[type=text]").each(
function() {
$(this).attr("value",""); --- 就是它了
}
);
}
前端js获取SpringMvc后台model中传值
使用 SpringBoot +SpringMVC +thymeleaf 组合实现的功能,期望在 thymeleaf 中的html中的js中 获取 springboot 中 Model 中设置的值
@Controller
@RequestMapping("/web/computerTest")
public class ComputerTestWebController {
/**
* 选择考试
*/
@GetMapping("/chooseExam.html")
public String chooseExam(@RequestParam String token, Model model) {
Boolean showV1 = true;
Boolean showPre = true;
model.addAttribute("showV1", showV1);
model.addAttribute("showPre", showPre);
//对应显示的html
return "computertestweb/chooseExamV2";
}
}
有两种方式:
1 内联js方式
<script th:inline="javascript">
let activityName = "first"
if([[${showV1}]]){
activityName = "first"
}else{
activityName = "second"
}
</script>
2、使用隐藏域,
使用隐藏域, 先把model的值通过标签的方式放到某个input标签下,再到js中通过js或者jquery按照id的方式选取
2.1 在html 中写入隐藏标签
<input type="hidden" id="showV1" value="${showV1}}">
2.2 在js中通过ID获取标签获取值
let data= $("#showV1").val();
mac 查看某个目录的大小
du -hd1 ; 与 centos 的有些不一样。 centos 下为du -h -x --max-depth=1