title: @ResponseBody in Spring mvc 4 send String but does not send any other Object to client side
body: <p>Spring Controller easily send String type Object towards Client side ajax/angularjs but not able to send any other object.</p>
  
  <p>I am using Spring mvc 4.1.4 , Maven , tiles , mysql , hibernate , jsp , ajax technologies in my project.
  Please help me for solving this problem. </p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  id="WebApp_ID" version="2.5"&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;DispatcherServlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;DispatcherServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  
  &lt;listener&gt;
      &lt;listener-class&gt;
          org.springframework.web.context.ContextLoaderListener
      &lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;   
  &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.mylogistics&lt;/groupId&gt;
  &lt;artifactId&gt;MyLogistics&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;name&gt;MyLogistics Webapp&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.webflow&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webflow&lt;/artifactId&gt;
          &lt;version&gt;2.4.1.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;  
        &lt;artifactId&gt;spring-core&lt;/artifactId&gt;  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;  
      &lt;/dependency&gt; 
  
      &lt;dependency&gt;  
       &lt;groupId&gt;org.springframework&lt;/groupId&gt;  
       &lt;artifactId&gt;spring-web&lt;/artifactId&gt;  
       &lt;version&gt;${org.springframework.version}&lt;/version&gt;  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;  
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;  
          &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;  
          &lt;version&gt;${org.springframework.version}&lt;/version&gt;  
      &lt;/dependency&gt;  
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-asm&lt;/artifactId&gt;
          &lt;version&gt;3.1.4.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
          &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
          &lt;version&gt;1.3.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;commons-io&lt;/groupId&gt;
          &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
          &lt;version&gt;2.4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;5.1.6&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;1.7.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
          &lt;version&gt;1.7.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springmodules&lt;/groupId&gt;
          &lt;artifactId&gt;spring-modules-validation&lt;/artifactId&gt;
          &lt;version&gt;0.8a&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;  
       &lt;groupId&gt;javax.servlet&lt;/groupId&gt;  
       &lt;artifactId&gt;jstl&lt;/artifactId&gt;  
       &lt;version&gt;1.2&lt;/version&gt;  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;  
       &lt;groupId&gt;javax.servlet&lt;/groupId&gt;  
       &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;  
       &lt;version&gt;3.0.1&lt;/version&gt;  
       &lt;scope&gt;provided&lt;/scope&gt;  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.validation&lt;/groupId&gt;
          &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.0.GA&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;  
          &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;  
          &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;  
          &lt;version&gt;2.2.6&lt;/version&gt;  
      &lt;/dependency&gt;  
  
      &lt;dependency&gt;  
          &lt;groupId&gt;javax.xml&lt;/groupId&gt;  
          &lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;  
          &lt;version&gt;2.1&lt;/version&gt;  
      &lt;/dependency&gt;
  
  &lt;!--Spring tiles  --&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-core&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-jsp&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-api&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-servlet&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-template&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-request-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.6&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-request-servlet&lt;/artifactId&gt;
          &lt;version&gt;1.0.6&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-mvel&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-request-freemarker&lt;/artifactId&gt;
          &lt;version&gt;1.0.6&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-request-mustache&lt;/artifactId&gt;
          &lt;version&gt;1.0.6&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-request-servlet-wildcard&lt;/artifactId&gt;
          &lt;version&gt;1.0.6&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-portlet-wildcard&lt;/artifactId&gt;
          &lt;version&gt;2.2.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-request-velocity&lt;/artifactId&gt;
          &lt;version&gt;1.0.6&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-velocity&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-el&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-extras&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-compat&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
  
      &lt;!--hibernate  --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;4.3.5.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;4.3.1.Final&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
          &lt;version&gt;2.4.3&lt;/version&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
          &lt;version&gt;2.4.3&lt;/version&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
          &lt;version&gt;2.4.3&lt;/version&gt;
       &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
          &lt;version&gt;1.9.12&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-core-asl&lt;/artifactId&gt;
          &lt;version&gt;1.9.13&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;net.java.dev.rome&lt;/groupId&gt;
          &lt;artifactId&gt;rome&lt;/artifactId&gt;
          &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;finalName&gt;MyTiles1-0.0.1-SNAPSHOT&lt;/finalName&gt;
  &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>applicationContext.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
     &lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xmlns:context="http://www.springframework.org/schema/context"
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;context:component-scan base-package="com.mylogistics.controller" /&gt;
  &lt;context:annotation-config /&gt;
  &lt;mvc:annotation-driven /&gt;
  
  &lt;bean id="viewResolver2"
      class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;property name="order" value="2"/&gt;
      &lt;property name="viewClass"&gt;
          &lt;value&gt;
              org.springframework.web.servlet.view.tiles3.TilesView
          &lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="tilesConfigurer"
      class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"&gt;
      &lt;property name="definitions"&gt;
          &lt;list&gt;
              &lt;value&gt;/WEB-INF/tiles.xml&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/logistics"/&gt;
          &lt;property name="username" value="root" /&gt;
          &lt;property name="password" value="" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="ds" /&gt;
       &lt;property name="annotatedClasses"&gt;
          &lt;list&gt;
          &lt;!--model package extention for db table  --&gt;
              &lt;value&gt;com.mylogistics.model.User&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="userDAO" class="com.mylogistics.DAO.UserDAOImpl"&gt;
      &lt;constructor-arg&gt;
          &lt;ref bean="sessionFactory" /&gt;
      &lt;/constructor-arg&gt;
  &lt;/bean&gt;
  
  &lt;!--JSON Converter  --&gt;
  &lt;bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"&gt;
      &lt;property name="messageConverters"&gt;
          &lt;list&gt;
              &lt;bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/&gt;
              &lt;bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/&gt;
              &lt;bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/&gt;
              &lt;bean class="org.springframework.http.converter.FormHttpMessageConverter"/&gt;
              &lt;bean class="org.springframework.http.converter.StringHttpMessageConverter"/&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  
  &lt;/bean&gt;
  &lt;bean id="jacksonMessageChanger"  class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"&gt;
  &lt;property name="supportedMediaTypes" value="application/json" /&gt;
  &lt;/bean&gt;
  
  &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
      &lt;property name="messageConverters"&gt;
          &lt;list&gt;
              &lt;ref bean="jacksonMessageChanger" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p> </p>
  
  <p>index.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;MyLogistics&lt;/title&gt;
  &lt;script type="text/javascript" src="/WEB-INF/js/jquery-1.11.2.js"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div&gt;
      &lt;center&gt;
               hello 
                          &lt;a href="/MyLogistics/login.html"&gt;login&lt;/a&gt;
      &lt;/center&gt;
   &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>indexController.java</p>
  
  <pre><code>package com.mylogistics.controller;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  @Controller
  @RequestMapping("/index.html")
  public class IndexController {
  @RequestMapping
  public String getIndexPage() {
  
      System.out.println("IndexController");
      return "index";
  }
  }
  </code></pre>
  
  <p>login.jsp</p>
  
  <pre><code>&lt;html&gt;
  &lt;header&gt;
  &lt;/header&gt;
  &lt;body&gt;
  &lt;script type="text/javascript" src="/WEB-INF/js/jquery-1.11.2.js"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"&gt;&lt;/script&gt;
  
  &lt;input type="button" value="hello" onclick = "test()"/&gt; 
  &lt;input type="text" id="map"/&gt;  
      &lt;script type="text/javascript"&gt;
          function test(){
          console.log("enter into test function of ajax")
              var para = "branchType=rohit";
  alert("abc");
              $.ajax({
                  type: "POST",
                  url: "/MyLogistics/hello.html",
                  dataType: "json",
                  /* data : JSON.stringify(user), */
                  contentType: "application/json",
                  data: para,
                  success: function(response){
                      // we have the response
                      $('#map').val(response.value2);
                      alert(response);
                  },
                  error: function(e){
                      alert('Error: ' + e.error);
                  }
              });
          }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>loginController.java</p>
  
  <pre><code>package com.mylogistics.controller
  @Controller
  public class loginCntlr {
  
  @RequestMapping("/login")  
  public String home() {  
      System.out.println("INSIDE HOME");
      return "login";  
  }
  
  @RequestMapping(value = "/hello", method=RequestMethod.POST,headers="application/json")
  public @ResponseBody Object helloTest(HttpServletRequest request,HttpServletResponse res){
  
      System.out.print("ok im here: "+request.getParameter("branchType"));
  
      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
      map.put("value1", "sanjana");
      map.put("value2", "shikha");
  
      System.out.println("ok im here: "+map.get("value1"));
  
      return map;
  }
  }
  </code></pre>