Announcement Announcement Module
Collapse
No announcement yet.
Existing ajax call failing after upgrade to Spring MVC 3.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Existing ajax call failing after upgrade to Spring MVC 3.2

    We recently upgraded to Spring 3.2. I had a basic ajax call (GET) which invoked a controller's method handler and returned a json reponse back. It now fails with a 400 response. I reverted back to our older Spring dependency of 3.1 and it works. So that's why I'm guessing that it's our use the new version causing this issue.

    here is the controller's method:

    Code:
    	@RequestMapping(value = "checkKeyWord", method = RequestMethod.GET)
    	public @ResponseBody String checkKeyword(final HttpSession session, HttpServletRequest request, @ModelAttribute CampaignKeywordAvailabilityRequest keywordAvailabilityRequest) {
    		String jsonResult = null;
    		TokenData tokenData = null;
    		Date modifiedEndDate =  keywordAvailabilityRequest.getCampaignEndDate();
    		Calendar midNightMinus1Sec = new GregorianCalendar();
    		midNightMinus1Sec.setTime(modifiedEndDate);
    		if(modifiedEndDate != null) {
    			midNightMinus1Sec.add(Calendar.DATE,1);
    			midNightMinus1Sec.add(Calendar.SECOND, -1);
    			keywordAvailabilityRequest.setCampaignEndDate(midNightMinus1Sec.getTime());
    		}
    		
    		try {
    			jsonResult = mobiService.checkKeywordAvailability(keywordAvailabilityRequest);
    		} catch (Exception e) {
    			LOGGER.info(e.getMessage());
    		}
    		return jsonResult;
    	}
    and here is the JS call (jQuery 1.7.2)

    Code:
    				$.ajax({
    					type: "get",
    					url: "checkKeyWord",
    					data: {
    						optInKeyword: _inKeyword,
    						optOutKeyword: _outKeyword,
    						campaignStartDate: _startDate,
    						campaignEndDate: _endDate,
    						campaignType: _campaignType,
    						orgId: _orgId
    					},
    					success: function(messageText){
    						jsonObject = $.parseJSON(messageText);
                                                    // other logic goes here
    					}
    				    });
    I do not see any JS errors at the time of page load. I can see the request URL correctly constructed:

    http://localhost:8080/campaignManage...+OptIn&orgId=1

    but as I mentioned Status Code:400 Bad Request is received. So obviously it's even getting to my controller. Is there something with the @ModelAttribute that I need handle differently?

    Regards,
    Kaz
Working...
X