Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何根据控制器条件隐藏/显示字段?_Java_Spring_Spring Mvc_Thymeleaf - Fatal编程技术网

Java 如何根据控制器条件隐藏/显示字段?

Java 如何根据控制器条件隐藏/显示字段?,java,spring,spring-mvc,thymeleaf,Java,Spring,Spring Mvc,Thymeleaf,我有一个带thymeleaf的Spring MVC应用程序 根据控制器方法中测试的条件,我想从视图输入span、div、button…中显示或隐藏html元素 怎么做?例如,在asp.net中,如果希望或不希望显示myButton.Visible=false或true,则可以执行该操作 有没有类似的春药可以在百里香酒店买到?谢谢。通过将属性传递给 并使用百里香的 演示: 包com.example.demo.controllers; 导入org.springframework.stereotype

我有一个带thymeleaf的Spring MVC应用程序

根据控制器方法中测试的条件,我想从视图输入span、div、button…中显示或隐藏html元素

怎么做?例如,在asp.net中,如果希望或不希望显示myButton.Visible=false或true,则可以执行该操作


有没有类似的春药可以在百里香酒店买到?谢谢。

通过将属性传递给 并使用百里香的

演示:

包com.example.demo.controllers; 导入org.springframework.stereotype.Controller; 导入org.springframework.ui.Model; 导入org.springframework.web.bind.annotation.GetMapping; 导入org.springframework.web.bind.annotation.RequestParam; @控制器 公共类微控制器{ @GetMapping/订单 公共字符串getCondition@RequestParamrequired=假字符串MyDine,模型{ model.addAttributemeal,MyDine; 返回用餐/用餐地点; } } 参考资料/模板/MEIN-site.html

热狗?
热狗 通过将属性传递给 并使用百里香的

演示:

包com.example.demo.controllers; 导入org.springframework.stereotype.Controller; 导入org.springframework.ui.Model; 导入org.springframework.web.bind.annotation.GetMapping; 导入org.springframework.web.bind.annotation.RequestParam; @控制器 公共类微控制器{ @GetMapping/订单 公共字符串getCondition@RequestParamrequired=假字符串MyDine,模型{ model.addAttributemeal,MyDine; 返回用餐/用餐地点; } } 参考资料/模板/MEIN-site.html

热狗?
热狗!令人惊叹的工作得很好。也适用于ModelAndView。非常感谢。回答:太棒了。工作得很好。也适用于ModelAndView。非常感谢。答案被接受。