Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.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 春天正在访问Thymeleaf中的配置变量。_Java_Spring_Thymeleaf - Fatal编程技术网

Java 春天正在访问Thymeleaf中的配置变量。

Java 春天正在访问Thymeleaf中的配置变量。,java,spring,thymeleaf,Java,Spring,Thymeleaf,我正在尝试将Spring中的配置变量传递给Thmyleaf模板。我已经成功地从配置文件中加载了带有注释值的变量,并可以通过System.out输出它。我只是无法在模板中呈现它 应用程序.yaml acmeUrl: url: https://www.acme.com 我的控制器 @Value("${acmeUrl.url}") private String acmeUrl; //grab from annotation and pass to the v

我正在尝试将Spring中的配置变量传递给Thmyleaf模板。我已经成功地从配置文件中加载了带有注释值的变量,并可以通过System.out输出它。我只是无法在模板中呈现它

应用程序.yaml

acmeUrl:
   url:         https://www.acme.com
我的控制器

   @Value("${acmeUrl.url}")
   private String acmeUrl;

   //grab from annotation and pass to the view
   modelView.addObject( "acmeUrl", this.acmeUrl );
我的Thmeleaf模板:

<span th:text="${acmeUrl}" />

以上工作。但是,当我尝试对返回querystring参数进行条件检查时,我什么也没有得到

<input type="hidden" name="return" th:value="${param.return != null ? param.return[0] : acmeUrl }" />

我的内联IF在这里看起来正确吗?很确定这是罪魁祸首,但不确定是否需要更改格式以使其正常工作?

根据这一点,正确的语法应该是: th:value=“${param.return!=null}?{param.return[0]}:{acmeUrl}”

根据这一点,正确的语法应该是: th:value=“${param.return!=null}?{param.return[0]}:{acmeUrl}”