Change date format in DTO JSON on returning through @ResponseBody

后端 未结 1 663
广开言路
广开言路 2021-01-22 09:59

I simply want to change the date format in my DTO returned by @ResponseBody

My question is not this question as my output is a JSON List and I am printing it on Postman

相关标签:
1条回答
  • 2021-01-22 10:23

    The 'jaxbContextFactory' bean is first defined in the 'webservicescommons-spring.xml' which creates the bean in the application context. So when you override the bean in your custom extension using (customExtension)-spring.xml, it is just overriding the bean in the application context. More information about context loading in Hybris can be found here.

    The typeAdapters property mentioned in your comments is defined in another bean which is defined in the 'jaxb-converters-spring.xml'

    <bean id="customJaxbContextFactory" parent="jaxbContextFactory">
            <property name="metadataSourceFactory" ref="customMetadataSourceFactory" />
            <property name="typeAdapters">
                <list>
                    <value>de.hybris.platform.webservicescommons.jaxb.adapters.DateAdapter</value>
                    <value>de.hybris.platform.webservicescommons.jaxb.adapters.StringMapAdapter</value>
                    <value>de.hybris.platform.webservicescommons.jaxb.adapters.XSSStringAdapter</value>
                </list>
            </property>
        </bean>
    

    Since the beans defined in the jaxb-converters-spring-xml are loaded in the WebApplicationContext, you will need to override this bean using the (customExtension)-web-spring.xml where you can define the bean and corresponding class in the websrc of your custom extension.

    0 讨论(0)
提交回复
热议问题