Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. package com.webService.controller;
  2.  
  3.  
  4. import org.springframework.web.bind.annotation.PathVariable;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RequestMethod;
  7. import org.springframework.web.bind.annotation.RestController;
  8. @RestController
  9. @RequestMapping("/service/greeting")
  10. public class SpringServiceController {
  11. @RequestMapping(value = "/{name}", method = RequestMethod.GET)
  12. public String getGreeting(@PathVariable String name) {
  13. String result="Hello "+name;
  14. return result;
  15. }
  16. }
  17.  
  18.  
  19.  
  20. <?xml version="1.0" encoding="UTF-8"?>
  21. <beans xmlns="http://www.springframework.org/schema/beans"
  22. xmlns:context="http://www.springframework.org/schema/context"
  23. xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  24. xmlns:p="http://www.springframework.org/schema/p"
  25. xsi:schemaLocation="
  26. http://www.springframework.org/schema/beans
  27. http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  28. http://www.springframework.org/schema/context
  29. http://www.springframework.org/schema/context/spring-context-4.0.xsd
  30. http://www.springframework.org/schema/mvc
  31. http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
  32. <context:component-scan base-package="com.webService.controller" />
  33. <mvc:annotation-driven />
  34. </beans>
  35.  
  36. <?xml version="1.0" encoding="UTF-8"?>
  37. <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">
  38. <display-name>SpringServiceSample</display-name>
  39. <welcome-file-list>
  40. <welcome-file>index.html</welcome-file>
  41. </welcome-file-list>
  42.  
  43.  
  44. <servlet>
  45. <servlet-name>rest</servlet-name>
  46. <servlet-class>
  47. org.springframework.web.servlet.DispatcherServlet
  48. </servlet-class>
  49. <load-on-startup>1</load-on-startup>
  50. </servlet>
  51.  
  52. <servlet-mapping>
  53. <servlet-name>rest</servlet-name>
  54. <url-pattern>/*</url-pattern>
  55. </servlet-mapping>
  56. </web-app>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement