Article From:https://www.cnblogs.com/sunshine5683/p/9913012.html

From: https://blog.csdn.net/eson_15/article/details/51366370

The principle of adding commodity is the same as adding commodity category, but it is more complex than adding commodity category, because there are many attributes of commodity, and there are many fields in the corresponding database. There is also an option to add commodity to upload pictures. This small piece of content will be explained separately in the next blog, because it involves a knowledge.Dot recognition is Struts 2 to achieve file upload function. No more nonsense. Now we begin to improve the code for adding commodity parts.

1. Add merchandise
1.1 UI Implementation of Adding Commodities
        Firstly, the code of adding commodity part to query.jsp is completed.

        Next, let’s look at the implementation of save.jsp:

 

Copy code ></span></div><pre>  1 <%@ page language=
Copy code ></span></div></div><p>        We mainly look at the custom method part of the JS code above, mainly defining the verification of the uploaded images. The specific analysis is as follows:</p><p><img src=

Then you can use a custom method to validate the image:

 

1.2 Background Implementation of Adding Commodities

 

Copy code ></span></div><pre> 1 @Controller(
Copy code ></span></div></div><h1><span id=2. Update commodity

2.1 UI Implementation of Updating Commodities

        First, look at the code for updating the merchandise section in query.jsp:

 

 

        Next, take a look at update.jsp:

 

Copy code ></span></div><pre>  1 <%@ page language=
Copy code ></span></div></div><p>        The updating part is basically the same as the updating of the commodity category. It will not be further elaborated. The following is the implementation of the background updating part:</p><p> </p><h2><span id=2.2  Background Realization of Updating Commodities

 

Copy code ></span></div><pre> 1 @Controller(
Copy code ></span></div></div><p>        Compared with updating the category of goods, the only operation of uploading more pictures is to process the uploaded pictures in the background. We will analyze the file uploading function of Struts2 in detail in the next blog.</p></div></div><div class= Post Views: 2

Leave a Reply

Your email address will not be published. Required fields are marked *