Thymeleaf construct URL with variable

后端 未结 5 901
夕颜
夕颜 2020-12-01 01:24

I have the following code setting a variable in my controller:

model.set(\"type\", type);

In the thymeleaf view I want to construct a form

5条回答
  •  隐瞒了意图╮
    2020-12-01 02:02

    You need concatenate string inside @{}.

    @{} is used for URL rewriting. Part of URL rewriting is keeping track of session. First time user request URL, app server adds to url ;jsessionid=somehexvalue and generates cookie with jsessionid. When client sends cookie during next request server knows client supports cookies. If server knows that client support cookies, server will not keep addind jsessionid in URL.

    My preferred way is literal substitution with the pipeline syntax (|).

    
    

    Thymeleaf path variable syntax is

    
    

    Reference: Thymeleaf Standard URL Syntax

提交回复
热议问题