.jsp文件中的Spring MVC表单不包括Apache Tiles

时间:2022-09-20 20:31:20

When I'm going to localhost:8080/app/admin/cities URL, my application gives me an error:

当我要去localhost:8080 / app / admin / cities URL时,我的应用程序给了我一个错误:

java.lang.IllegalArgumentException: Attribute 'value' is required when binding to non-boolean values

java.lang.IllegalArgumentException:绑定到非布尔值时,需要属性“value”

Tiles configuration file(tiles.xml):

Tiles配置文件(tiles.xml):

<definition name="base" template="/WEB-INF/views/tiles/layouts/admin.jsp">
    <put-attribute name="head" value="/WEB-INF/views/tiles/head.jsp" />
    <put-attribute name="nav" value="/WEB-INF/views/tiles/nav.jsp" />
    <put-attribute name="sidebar" value="/WEB-INF/views/tiles/sidebar.jsp" />
    <put-attribute name="body" value="" />
    <put-attribute name="scripts" value="/WEB-INF/views/tiles/scripts.jsp" />
</definition>

<definition name="admin/cities" extends="base">
    <put-attribute name="body" value="/WEB-INF/views/admin/cities.jsp" />
</definition>

Included file(cities.jsp):

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<form:form method="DELETE" commandName="list" >
    <table class="table table-bordered table-striped">
        <thead>
        <tr>
            <th></th>
            <th>
                <spring:message code="msg.city"/>
            </th>
            <th>
                <spring:message code="msg.region"/>
            </th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="city" items="${citiesList}">
            <tr>
                <td>
                    <form:checkbox path="list"  value="${city.id}"/>
                </td>
                <td>
                    <c:out value="${city.cityName}"/>
                </td>
                <td>
                    <c:out value="${getRegionName[city.region]}"/>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <input type="submit" value="Save Changes" />
</form:form>

There were no problems when I used this form in the solid .jsp file, before splitting it into tiles. I'll be thankful for any kind of advice.

在将此表单拆分为tile之前,我在solid .jsp文件中使用此表单时没有问题。我会感谢任何建议。

EDIT: controller method

编辑:控制器方法

@RequestMapping(value = "/cities")
public String citiesPage(Model model) {
    model.addAttribute("getRegionName", new GetRegionName());
    model.addAttribute("pageTitle", "cities");
    model.addAttribute("citiesList", cityService.getCities());
    model.addAttribute("list", new ListWrapper());
    return viewPath + "cities";
}

2 个解决方案

#1


0  

Could you add to your post the controller method associated? The problem seems to be related to the JSP checkbox field. I think you are not mapping correctly the path attribute.

你可以在帖子中添加相关的控制器方法吗?该问题似乎与JSP复选框字段有关。我认为你没有正确映射路径属性。

#2


0  

I solved the problem by adding tag library support

我通过添加标记库支持解决了这个问题

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

on top of my cities.jsp, although I already have this line in included head.jsp.

在我的cities.jsp之上,虽然我已经在head.jsp中包含了这一行。

#1


0  

Could you add to your post the controller method associated? The problem seems to be related to the JSP checkbox field. I think you are not mapping correctly the path attribute.

你可以在帖子中添加相关的控制器方法吗?该问题似乎与JSP复选框字段有关。我认为你没有正确映射路径属性。

#2


0  

I solved the problem by adding tag library support

我通过添加标记库支持解决了这个问题

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

on top of my cities.jsp, although I already have this line in included head.jsp.

在我的cities.jsp之上,虽然我已经在head.jsp中包含了这一行。