In today's MVC framework, it seems that WEBWORK2 is gradually becoming mainstream, and the combination of webwork2+springframework is becoming more and more popular. This seems to imply that spring's own MVC framework is far worse than WEBWORK2, so everyone is replacing it with WEBWORK2. Indeed, Spring's MVC framework is not a central part of the whole
annotations
Add note @controller to indicate that the controller class is adding methods
Add @requestmapping ("/xxx.do") to indicate the way to access the control layer @RequestMapping ("/xxxxx") can also be used to declare namespaces on a class2.4 Model data Processing
The return value of the method can be Modelandview,newmodelandview ("XXX", map), which is equivalent to putting the result data in the request
Define the map directly in the parameter list of the met
Spring 4 + jpa (hibernate 3/4) + spring mvc multi-data source configuration (2) + Druid connection pool, mvcdruid
Pick up a blog post (http://www.loveweir.com/html/18.html), no database connection pool, purely using the official link of jpa.
Therefore, we need to add the connection pool. In this article, we use the Druid connection pool to configure multiple data
) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/8C/CF/wKiom1h4mcWxh7SpAACc0dLT8Us684.png "style=" float : none; "title=" 1.png "alt=" Wkiom1h4mcwxh7spaacc0dlt8us684.png "/>650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/8C/CB/wKioL1h4mcagG8qCAACnGTx9wMk536.png "style=" float : none; "title=" 2.png "alt=" Wkiol1h4mcagg8qcaacngtx9wmk536.png "/>Clicking Run as->maven Install will download a lot of jar packages and the last build succeeds.650) this.width=650; "src=" Http://s5.51
; Property>Bean>3. Modify the language of the running environment after successful login // if ("EN" .equals (Logonuser.getlanguage ()) {Locale Localeen = new Locale (" en "," en " else if ("JA" .equals (Logonuser.getlanguage ())) {Locale LOCALEJP = new Locale ("ja", "JP" else {Locale Localeen = new Locale ("en", "en" 4. Define methods for acquiring classical Chinese contentprotected string GetMessage (String code,object ... params) {return messagesource.getmessage (code
Controller control page Jump processing foreground background data interactive access ServiceDAO Layer: @Repository Database access layer additions and deletions to the JPA specification of the Hibernate JAP warehouse JPA Automatic parsing method name using @query (sql| | HqlDomaon layer: The entity bean is the table of the database in which the @entity @Table correspondence between the PojoService Layer: @Service Implementation some JPA can parse without access to the DAO layer can not be resol
-define the location of the JSP file - Beanclass= "Org.springframework.web.servlet.view.InternalResourceViewResolver"> Propertyname= "prefix"value= "/web-inf/views/"/> Propertyname= "suffix"value= ". jsp"/> Propertyname= "Viewnames">Array>valuetype= "Java.lang.String">login*value>Array> Property> Bean>If you have multiple file paths (for example: webapp/), you can define multiple resolver, configure different viewnames or different mediatype to differentiate which
the message body itself is a JSON.This way, spring will do the processing when it receives the JSON and convert it to an object. This is not the time to use Request.getparameters to obtain this request information.See requests and responses from Jemeter:
Post Http://localhost:8060/tstbody
Post data:
{' OpenID ': ' JMeter ', ' sign ': ' Sign '}
[no cookies]
Request Headers:
connection:keep-alive
content-type:application/json
:
content-length:33
ho
1 PrefaceIn the history of the simplest Spring MVC tutorial (ix), we have implemented the image upload and display function, then, in this blog post, we further to the entity class (person) in the field "name" and the controller (PersonController) in the method Updatepersonlist as an example, the verification function of the parameters is realized.2 Annotation Example-parameter checkThe usual, first give th
the value of a positive number, the higher the precedence of the servlet, and the more loaded it will be when the app starts. When the value is the same, the container will select its own order to load - Load-on-startup>1Load-on-startup> servlet> servlet-mapping> Servlet-name>SpringmvcServlet-name> Url-pattern>/Url-pattern> servlet-mapping>Then follow the classpath path above to create the configuration file Spring-mvc.x
avoid unnecessary searches.When you save Pojo to the database, you want to return to the Success page, if you want to bring a bit of information at this time:@RequestMapping (value = "/user/save", method = Requestmethod.post)Public Modelandview saveuser (usermodel user, redirectattributes redirectattributes)Throws Exception {Redirectattributes.addflashattribute ("message", "Save user success!") ");//UseAddflashattribute, parameters do not appear in the URL address barreturn "
Spring MVC integrated Velocity template
Spring MVC
We used struts2 when using the traditional configuration file in a way that did not use the legendary 0 configuration. SPRING3 MVC can be thought of as having 100% 0 configured (in addition to configuring
Initial Spring MVC and initial springmvc
1.
1. Introduction to Spring MVC
Spring MVC is a follow-up product of SpringFrameWork and has been integrated into Spring Web Flow. The
Two. What is Spring MVC1.1 spring MVC?Spring MVC: A framework of simplified Web application development based on the MVC architecture (part of the spring framework) that separates data,
instance at a time. Spring MVC's Command object is basically Pojo, and the cost of creating an instance is very low.3. The JSP tags of Struts 2 use OGNL as the expression language. I personally feel that this language is too powerful, especially for direct accessto the act ion itself, which can easily be abused to repeat the mistakes of the past jspOf course, Struts 2 also has many features that are worth the spr
Spring has introduced annotations in programming starting with version 2.5, and users can use @requestmapping, @RequestParam, @ModelAttribute, and so on. Up to now, although the spring version has undergone a great change, but the characteristics of the annotation has been continued, and continue to expand, so that the vast number of developers of the hands of the more relaxed, this is inseparable from the
In the previous article, we mainly introduced the implementation of the file upload function under normal circumstances under the SPIRNG MVC environment. In the actual development, will also involve the upload file size and type restrictions, the next will be the SPIRNG MVC environment File upload size and type limitations, will also explain the file upload size Tomcat server bug problems and solutions.One,
Spring Framework and MVC principlesDirectory
Spring Framework
SPRINGMVC Working principle
Resources
Back to TopSpring Framework
Spring's current framework has a jar package that can be roughly divided into 6 main modules:
Core Container
AOP and Instrumentation
Messaging
Data access/integration
Web
Test
Spring MVC uses the features that Hibernate validator Framework can implement:1. Annotate Java Bean Declaration validation rules.2. Add a message error message source for internationalization configuration.3. Display the error message with the errors tag in spring form.Advantage:The code is concise.Realize:1. Use Hibernate validator to introduce at least two jar
First, @RequestMapping IntroductionUse @RequestMapping in spring MVC to map a request, that is, to specify which URL requests the controller can handle, which is equivalent to configuring the servlet in Web. xmlThe mapping effect is consistent. Let's look at the source code for the Requestmapping annotation class first:@Target ({elementtype.method, elementtype.type}) @Retention (retentionpolicy.runtime) @Do
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.