Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 854839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:59:21+00:00 2026-05-15T07:59:21+00:00

I am using Spring MVC on the server side, but in one of the

  • 0

I am using Spring MVC on the server side, but in one of the pages I decided to create an AJAX validation with jQuery rather than the default Spring validation.
Everything works great, except when I have to do a remote validation to check if a “title” already exists in the database.
For the javascript I have the following:

var validator = $("form").validate({
    rules: {
        title: {
            minlength: 6,
            required: true,
            remote: {
                url: location.href.substring(0,location.href.lastIndexOf('/'))+"/checkLocalArticleTitle.do",
                type: "GET"
            }
        },
        html: {
            minlength: 50,
            required: true
        }
    },
    messages: {
        title: {
            required: "A title is required.",
            remote: "This title already exists."
        }
    }

});

Then, I use Spring-Json to make this validation and give a response:

@RequestMapping("/checkLocalArticleTitle.do")
public ModelAndView checkLocalArticleTitle(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
    Map model = new HashMap();
    String result = "FALSE";
    try{
        String title = request.getParameter("title");
        if(!EJBRequester.articleExists(title)){
            result = "TRUE";
        }
    }catch(Exception e){
        System.err.println("Exception: " + e.getMessage());
    }
    model.put("result",result);
    return new ModelAndView("jsonView", model);
}

However, this does not work and the field “title” is never validated.
I think the reason for this is that I am returning an answer in the manner:

{result:"TRUE"}

when in fact, the answer should be:

{"TRUE"}

I don’t know how to return a single response like this one using a ModelAndView answer.

Another thing that is not working is the customized message for the “remote” validation:

    messages: {
        title: {
            required: "A title is required.",
            remote: "This title already exists."
        }
    },

The required message works, but not the remote message.
I looked around, but I didn’t see many people using Spring and jQuery at the same time. At least, not mixing with jQuery remote valdations and Spring-Json.
I would appreciate some help here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:59:21+00:00Added an answer on May 15, 2026 at 7:59 am

    I encountered the same problem with you.

    and now I do

    @RequestMapping(value = "/brand/check/exists", method = RequestMethod.GET)
    public void isBrandNameExists(HttpServletResponse response,
            @RequestParam(value = "name", required = false) String name)
            throws IOException {
        response.getWriter().write(
                String.valueOf(Brand.findBrandsByName(name).getResultList()
                        .isEmpty()));
    }
    

    May not be a good solution. But anyway, that works out.

    If there is a better way, please let me know 🙂

    Update:

    In Spring 3.0 we can use @ResponseBody to do this

    @RequestMapping(value = "/brand/exists/name", method = RequestMethod.GET)
    @ResponseBody
    public boolean isBrandNameExists(HttpServletResponse response,
            @RequestParam String name) throws IOException {
        return Brand.findBrandsByName(name).getResultList().isEmpty();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Spring MVC v3.1.0 and HDIV (HTTP Data Integrity Validator) v2.1.0 as server-side
I'm using Spring MVC and jquery autocomplete, my spring controller looks like this @RequestMapping(value
I am java developer, (using Spring-MVC) never worked much on javascript, But I would
I'm using asp.net mvc 3 with jquery unobtrusive validation. I recently changed from standard
Question I have created a server-side property level validation attribute. But instead of applying
I'm using spring-mvc and jquery uploadify to upload an image, my uploadify script saves
I am using spring mvc in my application,when i created user i have to
I am using Spring MVC 3.1.x with Tiles 2.2.2 (bootstrapped project with Roo) and
I am using Spring MVC with Hibernate. My page has a button that creates
I am using spring MVC 3.0 with the jqgrid plugin. I am building the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.