Notes for Spring MVC configuration validator in JSP


Validation introduced by Spring MVC

For any application, data validation on the client side is not safe and effective, which requires us to validate the validity of data on the server side at the time of development. Spring MVC itself has a good support for data validation on the server side. It can validate the data submitted to the server according to our prior agreement. Spring MVC will save the unqualified data information in the error object. These error information can also be displayed on the front-end JSP page through the tag provided by Spring MVC.

Notes on Spring MVC configuration validator

<mvc:annotation-driven validator="validator" /> 

When using Spring MVC to integrate hibernate-validator for form data validation (page tags use spring form-related tags), it is not known whether it is due to version or other reasons. It is necessary to put the above configuration in the front, data validation annotations (e.g. @size, @email, etc.) will take effect, and error binding classes will receive error information.

In addition, let’s talk about the differences between spring-servlet.xml and application Context.xml in spring mvc.

  1:spring-servlet.xmlIt reads and loads the configuration when dispatcher Servlet starts. ApplicationContext. XML is loaded when contextLoaderListener hears the server starts.

2: Not in useSpring MVC dispatcher ServletIn the control layer (such as struts2), application Context. XML can use all spring-related configurations separately; when used together, there are some specifications. Spr-servlet. XML is best loaded with beans containing Web components, such as controllers, view parsers and processor mappings, while contextLoaderListener loads other beans in the application, which are usually Drive the mid-tier and data-tier components of the application backend.

Thank you for reading, I hope to help you, thank you for your support on this site!

Recommended Today

Summary of import and export usage in JavaScript

import import 和 require 的区别 import 和js的发展历史息息相关,历史上 js没有模块(module)体系,无法将一个大程序拆分成互相依赖的小文件,再用简单的方法拼装起来。这对开发大型工程非常不方便。在 ES6 之前,社区制定了一些模块加载方案,最主要的有 CommonJS 和 AMD 两种。前者用于服务器,后者用于浏览器。ES6 在语言标准的层面上,实现了模块功能,而且实现得相当简单,完全可以取代 CommonJS 和 AMD 规范,成为浏览器和服务器通用的模块解决方案。也就是我们常见的 require 方法。 比如 `let { stat, exists, readFile } = require(‘fs’);` 。ES6 在语言标准的层面上,实现了模块功能。ES6 模块不是对象,而是通过export命令显式指定输出的代码,再通过import命令输入。 import 的几种用法: 1. import defaultName from ‘modules.js’; 2. import { export } from ‘modules’; 3. import { export as ex1 } from […]