「Spring」addAttributeでモデルModelを使用するサンプル
構文
Model addAttribute(Object attributeValue)
generated name を使用して、この Map に提供された属性を追加します。 真の規則名を正しく判別できないため、このメソッドを使用する場合、空の Collectionはモデルに追加されません。
パラメーター:
attributeValue – モデル属性値 (非 null)
使用例
@Controller
public class UserController {
@RequestMapping("/")
public String index(Model model) {
String target = "study skill become smart";
model.addAttribute("message", target);
return "/cft/index";
}
}