SpringMVC Ajax验证 [英] SpringMVC Ajax validation

查看:311
本文介绍了SpringMVC Ajax验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Spring Mvc 3形式POST到控制器,在控制器中我调用执行DML语句。我还有一个单独的验证类,实现Validator,并在我的控制器中调用。我做简单和复杂的验证在那里像检查如果用户名存在,并返回一个错误消息,如果存在。

I have a Spring Mvc 3 form that POST to a controller, in the controller i make calls to execute DML statements. I also have a separate validation class that implements Validator and is called in my Controller. I do both simple and complex validation in there like check if user name exist and return an error message if it exist.

我想使用ajax只验证用户名字段,当我在视图上的字段,但我想打电话到已经实现验证我有并且只验证用户名字段。

I would like to use ajax to validate only the user name field when i tab out of the field on the view, but i would like to make a call to the already implemented validation i have and only validate the username field.

我如何实现这一点,我需要在Ajax中调用Controller类,并有一个单独的@RequestMapping来处理这个?我可以有一个例子,如何这应该实现。

How can i achieve this, will i need to make a call in Ajax to the Controller class and have a separate @RequestMapping to handle this only? Can i have an example om how this should be implemented.

推荐答案

我在SpringFramework网站上阅读了一篇关于这个问题的非常好的教程文章。

I have read a very nice tutorial article on this issue on SpringFramework site.

请参阅此链接 a>。此外,还链接

Please refer this link. And this link also.

希望这有助于你。干杯。

Hope this helps you. Cheers.

这篇关于SpringMVC Ajax验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆