需要注意的是,在现在的Spring版本中,如果直接对Service进行注解,将会有产生警告:
按住Alt + Enter 修正错误,会看见提示:
官方推荐使用构造器注入
到此为止,后台工作就结束了
页面
接下来是JSP的编写:
首先是用户输入的页面 (ProductForm.jsp)
<body> <div> <form action="product_save" method="post"> <fieldset> <legend>Add a product</legend> <p> <label for="name">Product Name: </label> <input type="text"> </p> <p> <label for="price">Price: </label> <input type="text"> </p> <p> <label for="inventory">Inventory: </label> <input type="text"> </p> <p> <input type="reset" tabindex="4"> <input type="submit" tabindex="5" value="Add Product"> </p> </fieldset> </form> </div> </body>比较表单中的