
springboot thymeleaf返回的都是字符串不是页面
我上面用的是@RestController如果换成Controller的话会出现Circularviewpath[login]:woulddispatchbacktoth...
我上面用的是@RestController 如果换成Controller的话会出现Circular view path [login]: would dispatch back to the current handler URL [/login] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)访问localhost:8080/list出来的都是字符串"list"不是网页
展开
4个回答
展开全部
那是一定的。@RestController=@Controller+@ResponseBody,函数返回值会被当成responsebody来处理,因此如果需要返回页面,需要使用@Controller。
展开全部
夜泊牛渚怀古(李白)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在模板处理前,thymeleaf还会增加一个变量execInfo,比如${execInfo.templateName},${execInfo.now}等。
数据访问模式:
${...},变量引用模式,比如${myBean.property},如果用springDialect,则使用的是spring EL,如果不用spring,则用的ognl。
*{...},选择表达式,一般是th:object之后,直接取object中的属性。当没有选取对象时,其功能等同${...},*{firstName}也等同于${#object.firstName},#object代表当前选择的对象。
@{...}链接url的表达式。th:href="@{/xxx/aa.do(id=${o.id})",会自动进行url-encoding的处理。@{...}内部可以是需要计算的表达式,比如:
th:href=”@{'/details/'+${user.login}(orderId=${o.id})}"
#{...},i18n,国际化。
需要注意的:
#{${welcomeMsgKey}(${session.user.name})}:i18n message支持占位。各个表达式支持嵌套。
表达式基本对象:
#ctx:context object
#root或者#vars
#locale
#httpServletRequest
#httpSession
数据访问模式:
${...},变量引用模式,比如${myBean.property},如果用springDialect,则使用的是spring EL,如果不用spring,则用的ognl。
*{...},选择表达式,一般是th:object之后,直接取object中的属性。当没有选取对象时,其功能等同${...},*{firstName}也等同于${#object.firstName},#object代表当前选择的对象。
@{...}链接url的表达式。th:href="@{/xxx/aa.do(id=${o.id})",会自动进行url-encoding的处理。@{...}内部可以是需要计算的表达式,比如:
th:href=”@{'/details/'+${user.login}(orderId=${o.id})}"
#{...},i18n,国际化。
需要注意的:
#{${welcomeMsgKey}(${session.user.name})}:i18n message支持占位。各个表达式支持嵌套。
表达式基本对象:
#ctx:context object
#root或者#vars
#locale
#httpServletRequest
#httpSession
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询