Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring MVC HTTP状态400-客户端发送的请求在语法上不正确_Spring_Spring Mvc - Fatal编程技术网

Spring MVC HTTP状态400-客户端发送的请求在语法上不正确

Spring MVC HTTP状态400-客户端发送的请求在语法上不正确,spring,spring-mvc,Spring,Spring Mvc,我的项目对象 public class Item extends MyBaseObject { private String name; private Category category; private ItemType itemType; private String description; private Long reorderLevel; priv

我的项目对象

public class Item extends MyBaseObject {

    private String          name;
    private Category        category;
    private ItemType        itemType;
    private String          description;
    private Long            reorderLevel;
    private Long            freezeLevel;
    private Set<Inventory>  inventories = new TreeSet<>();
    private long            totalCount;
    private long            currentlyIssued;
    private long            availableStock;

    ... getter and setters
}

请帮忙。。。谢谢

您签出了吗?问题已解决订单模型属性项、模型模型、BindingResult结果,。。。应替换为ModelAttribute项、BindingResult、模型模型等,。。。BindingResult应该放在我们通过表单的对象之后。谢谢你的帮助。这篇文章真的帮助了我
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

<jsp:include page="/WEB-INF/views/common/head.jsp" />

<h2 class="demoHeaders">Item (Add New)</h2>

<form:form id="frmItemAdd" method="post" modelAttribute="item">
    <table class="vsform">
        <tbody>
            <tr>
                <td>
                    <form:label path="name"><spring:message code="item.name"></spring:message></form:label>
                </td>
                <td>
                    <form:input path="name" class="inputlarge required"/>
                    <form:errors path="name" class="errorMsg"/>
                </td>
            </tr>
            <tr>
                <td>
                    <form:label path="description"><spring:message code="item.description"></spring:message></form:label>
                </td>
                <td>
                    <form:textarea path="description" rows="5" cols="50" class="inputlarge"/>
                    <form:errors path="description" class="errorMsg"/>
                </td>
            </tr>
            <tr>
                <td>
                    <form:label path="category"><spring:message code="item.category"></spring:message></form:label>
                </td>
                <td>
                    <form:select path="category" class="myform inputlarge">
                        <form:options items="${listCategory}" itemLabel="name" itemValue="id"/>
                    </form:select>
                    <form:errors path="category" class="errorMsg"/>
                </td>
            </tr>
            <tr>
                <td>
                    <form:label path="itemType"><spring:message code="item.itemType"></spring:message></form:label>
                </td>
                <td>
                    <form:select path="itemType" class="myform inputlarge">
                        <form:options items="${listItemType}" itemLabel="name" itemValue="id"/>
                    </form:select>
                    <form:errors path="itemType" class="errorMsg"/>
                </td>
            </tr>
            <tr>
                <td>
                    <form:label path="reorderLevel"><spring:message code="item.reorderLevel"></spring:message></form:label>
                </td>
                <td>
                    <form:input path="reorderLevel" class="inputsmall required"/>
                    <form:errors path="reorderLevel" class="errorMsg"/>
                </td>
            </tr>
            <tr>
                <td>
                    <form:label path="freezeLevel"><spring:message code="item.freezeLevel"></spring:message></form:label>
                </td>
                <td>
                    <form:input path="freezeLevel" class="inputsmall required"/>
                    <form:errors path="freezeLevel" class="errorMsg"/>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button id="buttonReset" type="reset">Reset</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id="buttonSubmit">Submit</button>
                </td>
            </tr>
        </tbody>
    </table>
</form:form>

<jsp:include page="/WEB-INF/views/common/foot.jsp" />  
    @Controller
@RequestMapping("/ims/item/addNew")
public class ItemAddController extends InventoryBaseController {

    @Autowired
    private InventoryService inventoryService;

    @Autowired
    private ItemAddValidator itemAddValidator;

    @ModelAttribute("listCategory")
    public List<Category> getListCategory(){
        return inventoryService.listCategory();
    }

    @ModelAttribute("listItemType")
    public List<ItemType> getListItemType(){
        return inventoryService.listItemType();
    }

    @RequestMapping(method=RequestMethod.GET)
    public String itemAdd(Model model, RedirectAttributes reat, Principal principal){

        Item item = new Item();

        model.addAttribute("item", item);
        return "manager/item/itemAdd";
    }

    @RequestMapping(method=RequestMethod.POST)
    public String itemAdd(@ModelAttribute Item item, Model model, BindingResult result, RedirectAttributes reat, Principal principal){
        this.itemAddValidator.validate(item, result);
        if (result.hasErrors()){
            return "manager/item/itemAdd";
        }

        item.setAddDefaults(principal.getName());
        if (this.inventoryService.addItem(item)){
            reat.addFlashAttribute("message", "Item record added successfully.");
        } else {
            reat.addFlashAttribute("message", "Item record not added.");
        }
        return "redirect:/ims/item/addNew";
    }
}
typeMismatch=Could not convert to the required type.
typeMismatch.java.util.Calendar=Please enter date in the dd-MM-yyyy format.
typeMismatch.java.math.BigDecimal=Please enter value in correct format 0.00
typeMismatch.java.lang.Long=Must specify an integer value.