Advertisement
Guest User

Untitled

a guest
Jun 16th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.11 KB | None | 0 0
  1. @RequestMapping(value = {"/categories"}, method = RequestMethod.GET, headers = "Accept=application/json")
  2. @ResponseBody
  3. public ResponseEntity<String> getCategories() throws ParseException, UnsupportedEncodingException {
  4.  
  5. List<Category> categories= postService.getCategories();
  6.  
  7. HttpHeaders headers = new HttpHeaders();
  8. headers.add("Content-Type", "application/json; charset=utf-8");
  9.  
  10. if (categories == null) {
  11. return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
  12. }
  13.  
  14. return new ResponseEntity<String>(JSONResponseUtil.getJSONString(categories), headers, HttpStatus.OK);
  15. }
  16.  
  17. <?xml version="1.0" encoding="UTF-8"?>
  18. <beans xmlns="http://www.springframework.org/schema/beans"
  19. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  20. xmlns:aop="http://www.springframework.org/schema/aop"
  21. xmlns:context="http://www.springframework.org/schema/context"
  22. xmlns:mvc="http://www.springframework.org/schema/mvc"
  23. xmlns:tx="http://www.springframework.org/schema/tx"
  24. xmlns:jdbc="http://www.springframework.org/schema/jdbc"
  25. xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
  26. xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
  27. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
  28. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
  29. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  30. http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
  31. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  32. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
  33.  
  34.  
  35. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
  36. <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
  37. <property name="url" value="jdbc:oracle:thin:@:1521:ORCL" />
  38. <property name="username" value="" />
  39. <property name="password" value="" />
  40. <property name="maxActive" value="20" />
  41. <property name="maxWait" value="6000" />
  42. <property name="poolPreparedStatements" value="true" />
  43. <property name="defaultAutoCommit" value="true" />
  44. <property name="initialSize" value="10" />
  45. <property name="maxIdle" value="20" />
  46. <property name="validationQuery" value="select sysdate from dual" />
  47. <property name="testWhileIdle" value="true" />
  48. <property name="timeBetweenEvictionRunsMillis" value="7200000" />
  49. </bean>
  50.  
  51.  
  52. <bean id="transactionManager"
  53. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  54. <property name="dataSource" ref="dataSource" />
  55. </bean>
  56.  
  57.  
  58. <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
  59. <property name="typeAliasesPackage" value="acutls.model" />
  60. <property name="dataSource" ref="dataSource" />
  61. <property name="configLocation" value="/WEB-INF/mybatis-config.xml" />
  62. <property name="mapperLocations">
  63. <array>
  64. <value>classpath*:/acutls/mybatis/repository/mapper/**/*.xml</value>
  65. </array>
  66. </property>
  67. </bean>
  68.  
  69. <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
  70. <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactoryBean" />
  71. </bean>
  72.  
  73. <tx:annotation-driven transaction-manager="transactionManager" />
  74.  
  75. <?xml version="1.0" encoding="UTF-8"?>
  76. <beans xmlns="http://www.springframework.org/schema/beans"
  77. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  78. xmlns:context="http://www.springframework.org/schema/context"
  79. xmlns:mvc="http://www.springframework.org/schema/mvc"
  80. xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
  81. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  82. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
  83.  
  84. <context:component-scan base-package="acutls" />
  85.  
  86. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  87. </bean>
  88. <context:annotation-config />
  89. <mvc:annotation-driven/>
  90. <mvc:resources location="/UploadedImage/" mapping="/UploadedImage/**"/>
  91. <mvc:resources location="/resources/" mapping="/resources/**"/>
  92.  
  93. <mvc:view-controller path="/Login" view-name="/resources/templates/login.html"/>
  94. <mvc:view-controller path="/" view-name="/resources/templates/index.html"/>
  95.  
  96. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
  97. <property name="messageConverters">
  98. <list>
  99. <bean class="org.springframework.http.converter.StringHttpMessageConverter">
  100. <property name="supportedMediaTypes">
  101. <list>
  102. <value>application/json;charset=utf-8</value>
  103. <value>application/json</value>
  104. </list>
  105. </property>
  106. </bean>
  107. </list>
  108. </property>
  109. </bean>
  110.  
  111.  
  112. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement