Thymeleaf无法解析表达式:选择选项

时间:2017-10-22 06:59:21

标签: spring-boot thymeleaf

我无法弄清楚我的错误。这是我的updateprofile.html。

<select class="form-control selectpicker" th:value = "${user.team}" id="team" name="team" roleId="team" required="required">
    <option disabled="disabled">Select your team</option>
    <option th:selected="${user.team} == 'A'}">A</option>
    <option th:selected="${user.team} == 'B'}">B</option>
    <option th:selected="${user.team} == 'C'}">C</option>
    <option th:selected="${user.team} == 'D'}">D</option>  
    <option th:selected="${user.team} == 'TSO'}">TSO</option>   
</select>

错误是

  

org.thymeleaf.exceptions.TemplateProcessingException:无法解析   表达式:“$ {user.team} =='A'}”(updateprofile:54)

这是我的控制器类

@RequestMapping(value = "/updateprofile", method = RequestMethod.GET)
public String updateProfile(Principal principal, Model model) {
    User user = userService.findByUsername(principal.getName());
    model.addAttribute("user", user);
    return "updateprofile";
}

提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

你的百里香表达式中有额外的componentWillReceiveProps(nextProps) { if (nextProps.name !== this.props.name) { console.log(this.props.name, nextProps.name); } }

试试这个

}