java - thymeleaf和spring集成后Spring EL表达式无效
PHPz
PHPz 2017-04-17 17:48:31
0
1
452

表达式无法被解析的原因是什么?
Controller

页面标签

显示内容

PHPz
PHPz

学习是最好的投资!

reply all(1)
巴扎黑

In Spring’s Controller method, the Model is injected through method parameters
Similar to this:

@RequestMapping("welcome")
public String welcome(Model model) {
    model.addAttribute("whatever", new SomeObject());
    return "welcome";
}

If you use ModelAndView, do this

@RequestMapping("welcome")
public ModelAndView welcome() {
    ModelAndView mv = new ModelAndView("welcome");
    mv.addObject("whatever", new SomeObject());
    return mv;
}

In addition, shouldn’t it be written like this in View?

<tr>
  <th th:text="#{whatever}">Name</th>
  <th th:text="#{whatever}">Price</th>
</tr>
It is recommended to ask questions in the future. Do not take screenshots of the code. Use text. It is best to attach the complete source code and put it in the git repository.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template