ModelAndView + springMVC form:form

    xiaoxiao2026-02-25  9

    后台使用ModelAndView,在前台可以使用springmvc中,form标签,来接收值。

    <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> <form:form id="testform" commandName="form" action="${ctx}/login/form/form"> <form:input path="name" id="nm"/> <button>这个是form 页面</button> </form:form> commandName="form"

    这里的form,就是在controller 中,

    Map<String, Object> model = new HashMap<String, Object>();  model.put("form", form); 如果你put("aaa",AAA);

    就是commandName="aaa"了。

    如果不写这个,会报错如下:

    Neither BindingResult nor plain target object for bean name 'command' available as request attribute

    相关资源:python入门教程(PDF版)
    最新回复(0)