Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
将JavaScript与Thymeleaf结合使用_Javascript_Spring Boot_Thymeleaf - Fatal编程技术网

将JavaScript与Thymeleaf结合使用

将JavaScript与Thymeleaf结合使用,javascript,spring-boot,thymeleaf,Javascript,Spring Boot,Thymeleaf,我有一个html表单,它使用了Thymeleaf和SpringBoot。在我的表格中,我有两个选择,硬件或软件。我已经知道了如何根据选择的单选按钮隐藏每个部分,但是我在实际使用其中一个按钮上的数据时遇到了困难。我的意思是: Top of form: Radio input: Hardware, Software if(Hardware selected) Show "Hardware Question Section" Hide "Software

我有一个html表单,它使用了Thymeleaf和SpringBoot。在我的表格中,我有两个选择,硬件或软件。我已经知道了如何根据选择的单选按钮隐藏每个部分,但是我在实际使用其中一个按钮上的数据时遇到了困难。我的意思是:

Top of form:
Radio input:
Hardware,
Software

if(Hardware selected)
    Show "Hardware Question Section"
    Hide "Software Question Section"
    Form th:action should be hardware form object
    Spring controller for form should disregard software object and NOT throw any errors
    Form should submit to hardware url (mm/add-new-entry/hardware)
    If error with form, redirect back and notify user.

if(Software selected)
    Show "Hardware Question Section"
    Hide "Software Question Section"
    Form th:action should be hardware form object
    Spring controller for form should disregard software object and NOT throw any errors
    Form should submit to hardware url (mm/add-new-entry/hardware)
    If error with form, redirect back and notify user.


使用Thymeleaf和JavaScript是否可以实现这一点?我知道我需要将逻辑放入Java中,以确保如果选择了一个,另一个不会出错。

是的,使用JS&Thymeleaf是可能的。将硬件和软件部分放在2个不同的分区或具有不同ID的分区中。根据无线电输入显示/隐藏硬件/软件分区。还要将逻辑放入Java中,以确保如果选择了一个,那么另一个不会出错