Guest User

Untitled

a guest
Jul 15th, 2012
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. The requested resource is not available Spring 3 MVC
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <beans xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xmlns:p="http://www.springframework.org/schema/p"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
  7.  
  8. <bean id="viewResolver"
  9. class="org.springframework.web.servlet.view.InternalResourceViewResolver"
  10. p:prefix="/WEB-INF/jsp/"
  11. p:suffix=".jsp"/>
  12.  
  13. </beans>
  14.  
  15. <?xml version="1.0" encoding="UTF-8"?>
  16. <web-app version="3.0"
  17. xmlns="http://java.sun.com/xml/ns/javaee"
  18. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  20.  
  21. <context-param>
  22. <param-name>contextConfigLocation</param-name>
  23. <param-value>
  24. /WEB-INF/applicationContext-main.xml
  25. /WEB-INF/applicationContext-hibernate.xml
  26. /WEB-INF/applicationContext-jms.xml
  27. /WEB-INF/applicationContext-i18n.xml
  28. </param-value>
  29. </context-param>
  30.  
  31. <listener>
  32. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  33. </listener>
  34.  
  35. <servlet>
  36. <servlet-name>dispatcher</servlet-name>
  37. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  38. <init-param>
  39. <param-name>contextConfigLocation</param-name>
  40. <param-value>/WEB-INF/applicationContext-dispatcher.xml</param-value>
  41. </init-param>
  42. <load-on-startup>1</load-on-startup>
  43. </servlet>
  44. <servlet-mapping>
  45. <servlet-name>dispatcher</servlet-name>
  46. <url-pattern>*.htm</url-pattern>
  47. </servlet-mapping>
  48.  
  49. <session-config>
  50. <session-timeout>
  51. 30
  52. </session-timeout>
  53. </session-config>
  54.  
  55. <welcome-file-list>
  56. <welcome-file>redirect.jsp</welcome-file>
  57. </welcome-file-list>
  58.  
  59. </web-app>
  60.  
  61. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  62. <% response.sendRedirect("index.htm"); %>
  63.  
  64. @Controller
  65. public class IndexController {
  66.  
  67. @RequestMapping("/index.htm")
  68. public String handleIndexGet() {
  69. return "index"; // forward to view index.jsp
  70. }
  71.  
  72. }
  73.  
  74. "<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  75. pageEncoding="ISO-8859-1"%>
  76.  
  77. http://localhost:8080/project-name/WEb-INF/nameofpage.jsp
  78.  
  79. package your.apckage.name;
  80.  
  81. import org.springframework.stereotype.Controller;
  82. import org.springframework.web.bind.annotation.RequestMapping;
  83. import org.springframework.web.bind.annotation.RequestMethod;
  84.  
  85. @Controller
  86. public class SampleController {
  87.  
  88. @RequestMapping(value = "/index", method = RequestMethod.GET)
  89. public String sample() {
  90. return "index";
  91. }
  92. }
  93.  
  94. <context:component-scan
  95. base-package="package name of the controller" />
  96.  
  97. <% response.sendRedirect("index.jsp"); %>
Advertisement
Add Comment
Please, Sign In to add comment