Spring mvc development process knowledge point record, springmvc
To create a small project for a customer, you must enter a URL similar to http://dd.yy/xxxxthen and then upload it to the library file under another domain name. (In reality, many short website sites provide APIs for calling, but the customer needs to create a short website service and then jump to another website on the server to download the corresponding books)
I have no experience in spring development, but I have little experience in java, therefore, record the problems encountered during the development process and valuable knowledge points for you and the future. Some areas may be wrong. for emergency purposes, please keep the function available first. Further research to improve JAVA development skills.
The following configurations are basically based on the video watching side.
Configuration:
1. web. xml
The Section for introducing spring servelet is as follows:
<Servlet> <servlet-name> volume URL </servlet-name> <servlet-class> org. springframework. web. servlet. dispatcherServlet </servlet-class> <load-on-startup> 1 </load-on-startup> <! -- Load springmvc. xml --> <init-param> <param-name> contextConfigLocation </param-name> <param-value> classpath: springmvc. xml </param-value> </init-param> </servlet>
2. springmvc. xml
Refer to the annotation development mode used in the video. The configuration is as follows:
<Context: component-scan base-package = "ren. kss. web. controller"> </context: component-scan> <! -- Annotation --> <bean class = "org. springframework. web. servlet. mvc. method. annotation. RequestMappingHandlerMapping"/> <! -- Annotation adapter --> <bean class = "org. springframework. web. servlet. mvc. method. annotation. RequestMappingHandlerAdapter"/> <! -- View parser --> <bean class = "org. springframework. web. servlet. view. internalResourceViewResolver "> <property name =" prefix "value ="/WEB-INF/jsp/"/> <property name =" suffix "value = ". jsp "/> </bean>
Dependency package
Follow the video to put some jar files in the created folder lib, and add lib to build path,
Some jar packages that are made up in patchwork. The version is not in the video, and some jar packages are not needed.
Garbled problem:
Read the address of the book in MYSQL and jump to the corresponding book file for download. The path is the virtual directory of the book, such as [http://domain.com/book/sharing /big data era _ life, great changes in work and thinking (zhanlu culture • fortune exchange) -Victor Mayr-Schönberger & juth cokeye. mobi], using URLEncoder based on previous experience. encode (url, "UTF-8"), does not include some special characters such "(). -"The content can be downloaded normally, but an error occurs when a special character is converted to % xx. An error also occurs when the database path is read directly and then converted to a url. The final solution is downloadUrl = new String (downloadUrl. getBytes ("UTF-8"), "ISO8859-1 ");