Want to know spring mvc interceptor annotation example? we have a huge selection of spring mvc interceptor annotation example information on alibabacloud.com
Spring MVC data verification-validate annotation method, mvcvalidate1. Description
Before learning the annotation method, you should first learn the encoding method spring injection. This helps you understand how the verification framework works. When an error occurs, the pr
Network-based improvement: the most normal versionCopy codeThe Code is as follows:Xmlns = "http://www.springframework.org/schema/beans"Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"Xmlns: p = "http://www.springframework.org/schema/p"Xmlns: context = "http://www.springframework.org/schema/context"Xsi: schemaLocation = "http://www.springframework.org/schema/beansHttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdHttp://www.springf
When returning data to the client using the @responsebody annotation in the Spring MVC controller, if there is no special setting, the Chinese will be garbled and the following code should be added to the Spring-mvc.xml configuration file.class= " Org.springframework.http.converter.json.MappingJacksonHttpMessageConvert
the backend controller are the same, but it is not the controller method inside, it is important to note that the front end has defined the parameter rules (that is, must be entered):RequiredIs this input is not empty, just start testing, I put the method inside the parameters are all shielded so that is certainly not to the method inside, before the time is with parameters, but also to the method inside, before using the annotation development with
Initialize data based on spring MVC annotation Project Startup
The comment section is not written ....
the Onapplicationevent method for implementing Applicationlistener can be executed at project startup.
@SuppressWarnings ("Rawtypes")
@Repository Public
class GetData implements applicationlistener{
@ autowired
@Qualifier ("Pagedao")
p
@ResponseBodyIn the @controller class method, you can have the string return content directly.The class whose return processing is Org.springframework.http.converter.StringHttpMessageConverter, which is the default encodingTo customize the return code, you need to configure:Spring MVC annotation @responsebody returns content encoding issues
Maven Project Build spring boot + spring mvc + JPA example, mavenmvc
This article describes how to build spring boot + spring mvc + JPA by using Maven:
Add
At the beginning of Servlet 3.0, Web projects can be completely web.xml configuration files, so the configuration of this article is only valid in web containers that support Servlet 3.0 and above
Using spring MVC (4.3.2.RELEASE) + thymeleaf (3.0.2.RELEASE), the spring jdbctemplate used by the persistence layer, PS: Recommend a very useful framework for the Jdbc
Recently, I encountered a very strange problem. Spring controller can inject objects, but it cannot inject placehoder with @ value, while other @ values are normal.
It was suddenly found that this was a strange problem. In web. XML, both spring-MVC Servlet and spring context listener were configured. This causes two s
Pring How MVC returns JSON data, there are probably several:
Spring MVC 3.0 method to return JSON data1. Direct PrintWriter output2. Use JSP view3. Using Spring's built-in support
The following are the configurations before 3.1:
here's the point.
The following configuration is 3.1 :
Use requestmappinghandlermapping and requestmappinghandleradapter after
This article is based only on the Spring MVC framework and does not integrate other components such as Hibernate. The spring version used is spring-framework-3.2.2.release-dist.
First the need to copy the package to the Lib folder, in order to be simple, the Spring3.2.2 in the Libs file of the package are copied past,
passed to the Foreground.The JSON is similar to: {"002": {"age": 122, "name": "smooth employment"}, This kind of information,Use JS code to Parse:1 $.ajax ({2Url: "first.do",3Success:function (data) {//data refers to what is printed from the server to the browser4 //jsonstring Jsonobject5 //{"001": {"age": 122, "name": "smooth employment"}}6var result= eval ("(" +data+ ")");7 8 }9});Here: Spring's Default JSON protocol parsi
urlPathHelper of the two HandlerMapping must be set, if no direct interface is called, you can just listen to Spring bean instantiation and create a class as follows:/* Solves the xss attack caused by @ PathVariable annotation. Note: This class must be initialized by WebApplicationContext */Public class XssHandlerMappingPostProcessor implements BeanPostProcessor {@ OverridePublic Object postProcessBeforeIn
Build the spring MVC process
Directory structure:
Process is as follows
1 jar packages that need to be imported with SPRINGMVC
2 in Web.xml need to add the following configuration
3 config file under Web-inf
It turns out that completely of
4 controller classes are as follows:
Package Com.sm.nothing.controller;
Import Org.springframework.stereotype.Controller;
Import org.springframework.w
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.