Announcement Announcement Module
Collapse
No announcement yet.
how to change the response format in springs? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to change the response format in springs?

    hi everybody,
    i have one service response as like below

    {"sectionsList":[{"name":"Mens Apparel","id":1},{"name":"Mens Accessories","id":2},{"name":"Mens FootWear","id":3},{"name":"Featured Brands","id":4}]}

    but ineed only the response which in bold letters

    pls help me and below is my configuration file

    [ code]

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="org.mss.controller" />
    <bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName"
    value="com.mysql.jdbc.Driver">
    </property>
    <property name="url" value="jdbc:mysql://localhost/xyz"></property>
    <property name="username" value="root"></property>
    <property name="password" value="xxxxx"></property>
    </bean>
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.MySQLDialect
    </prop>
    </props>
    </property>
    <property name="mappingResources">
    <list>
    <value>org/mss/bean/Mobile.hbm.xml</value>
    <value>org/mss/bean/Sections.hbm.xml</value>
    <value>org/mss/bean/Collections.hbm.xml</value>
    <value>org/mss/bean/Products.hbm.xml</value>
    </list>
    </property></bean>
    <bean id="SectionsDAO" class="org.mss.bean.SectionsDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="MobileDAO" class="org.mss.bean.MobileDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>



    <!-- To enable @RequestMapping process on type level and method level -->
    <bean class="org.springframework.web.servlet.mvc.annotat ion.DefaultAnnotationHandlerMapping" />
    <bean class="org.springframework.web.servlet.mvc.annotat ion.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
    <list>
    <ref bean="jsonconverter"/>
    </list>
    </property>
    </bean>
    <bean id="jsonconverter" class="org.springframework.http.converter.json.Map pingJacksonHttpMessageConverter">
    <property name="objectMapper" ref="omapper"/>
    <property name="supportedMediaTypes" value="application/json"/>
    </bean>
    <bean id="omapper" class="org.codehaus.jackson.map.ObjectMapper"/>
    <bean class="org.springframework.web.servlet.view.Conten tNegotiatingViewResolver">
    <property name="defaultContentType" value="application/json" />
    <property name="ignoreAcceptHeader" value="true" />
    <property name="favorPathExtension" value="true" />
    <property name="mediaTypes">
    <map>
    <entry key="json" value="application/json" />
    </map>
    </property>
    <property name="defaultViews">
    <list>
    <bean id="j" class="org.springframework.web.servlet.view.json.M appingJacksonJsonView">
    <property name="contentType" value="application/json"/>
    <property name="objectMapper" ref="omapper"/>
    </bean>
    </list>
    </property>
    </bean>
    <bean id="mobileController" class="org.mss.controller.MobileController">
    <property name="mobileDao" ref="MobileDAO" />
    <property name="sectionsDao" ref="SectionsDAO" />
    <property name="collectionsDao" ref="CollectionsDAO" />
    <property name="productsDao" ref="ProductsDAO" />
    </bean>



    <bean id="CollectionsDAO" class="org.mss.bean.CollectionsDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="ProductsDAO" class="org.mss.bean.ProductsDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean></beans>
    [/code ]
    please modify the code and send me the reply quickly

    Thank u very much
    Last edited by nagarjuna; Jul 18th, 2011, 02:33 AM.

  • #2
    Use [ code][/ode ] tags when posting code !!! !!! especially if you are demanding use to fix your code ...

    please modify the code and send me the reply quickly
    A bit politer would be nice... We can help you to guide you in the right direction but we aren't going to do your work for you...

    Comment

    Working...
    X