Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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带有Hibernate注释_Spring_Hibernate_Annotations_Request - Fatal编程技术网

客户端发送的请求在语法上不正确,Spring带有Hibernate注释

客户端发送的请求在语法上不正确,Spring带有Hibernate注释,spring,hibernate,annotations,request,Spring,Hibernate,Annotations,Request,我到处都在搜索这个错误,并用相同的标题浏览了这里的每一个线程,在我的代码中做了很多更改,但错误仍然存在 它说: HTTP Status 400 - type Status report message description The request sent by the client was syntactically incorrect. Apache Tomcat/7.0.35 我的控制器代码是: @RequestMapping(value = "/manageInventory.

我到处都在搜索这个错误,并用相同的标题浏览了这里的每一个线程,在我的代码中做了很多更改,但错误仍然存在

它说:

HTTP Status 400 -

type Status report

message

description The request sent by the client was syntactically incorrect.
Apache Tomcat/7.0.35
我的控制器代码是:

@RequestMapping(value = "/manageInventory.htm", method = RequestMethod.GET)
    public ModelAndView manageInventory(HttpSession session) {

        ArrayList<Product> products = new ArrayList<Product>();
        Manufacturer manufacturer = (Manufacturer) manufacturerDAO
                .getByUsername(((UserAccount) session.getAttribute("user"))
                        .getUsername());
        products = productDAO.getProductListByManufacturer(manufacturer
                .getManufacturerName());
        System.out.print(products.get(0).getProductName());
        ModelAndView view = new ModelAndView("manageInventory");
        view.addObject("products", products);
        InventoryItem inventoryItem = new InventoryItem();
        view.addObject("inventoryItem", inventoryItem);
        return view;
    }

    @RequestMapping(value = "/manufacture.htm", method = RequestMethod.POST)
    public ModelAndView manufactureProduct(HttpSession session, BindingResult result,
            @ModelAttribute("inventoryItem") @Valid InventoryItem inventoryItem) {

        System.out.print(result.getErrorCount()+" "+result.getAllErrors());

        ModelAndView view = null;
        if(!result.hasErrors())
        {
        Manufacturer manufacturer = manufacturerDAO
                .getByUsername(((UserAccount) (session.getAttribute("user")))
                        .getUsername());
        inventoryItem.setAvailability(true);
        inventoryItem.setManufacturer(manufacturer);
        manufacturer.getInventory().add(inventoryItem);
        manufacturerDAO.update(manufacturer);
        view =  new ModelAndView("done");
        }
        else
        {
            view = new ModelAndView("manageInventory");
        }
        return view;

    }

请帮忙。提前感谢。

我忘了在方法输入参数中添加
HttpServletRequest
。 我添加了它,它开始工作。奇怪,但奏效了。:)

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<body>
    <h2>Add Inventory</h2>
    <br />
    <form:form modelAttribute="inventoryItem" action="manufacture.htm" method="post">
        <table>
            <tr>
                <td>Select Product:</td>
                <td><form:select path="product">
                        <c:forEach var="product" items="${products}">
                            <form:option value="${product}">${product.productName}</form:option>
                        </c:forEach>
                </form:select></td>
                <td>Select Quantity:</td>
                <td>
                <form:input path="quantity" placeholder="Quantity"/><br />
                <font color="red"><form:errors path="quantity"/> </font>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center"><input type="submit" value="Manufacture">
                </td>
            </tr>
        </table>
    </form:form>
</body>
@NotNull
    private int quantity;