配置Web.xml文件

双击打开WebContent/WEB-INF/web.xml

在display-name节点和welcome-file-list节点之间,添加以下内容

  1. <filter>
  2. <filter-name>nutz</filter-name>
  3. <filter-class>org.nutz.mvc.NutFilter</filter-class>
  4. <init-param>
  5. <param-name>modules</param-name>
  6. <param-value>net.wendal.nutzbook.MainModule</param-value>
  7. </init-param>
  8. </filter>
  9. <filter-mapping>
  10. <filter-name>nutz</filter-name>
  11. <url-pattern>/*</url-pattern>
  12. </filter-mapping>

完成后完整的web.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 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">
  3. <display-name>nutzbook</display-name>
  4. <filter>
  5. <filter-name>nutz</filter-name>
  6. <filter-class>org.nutz.mvc.NutFilter</filter-class>
  7. <init-param>
  8. <param-name>modules</param-name>
  9. <param-value>net.wendal.nutzbook.MainModule</param-value>
  10. </init-param>
  11. </filter>
  12. <filter-mapping>
  13. <filter-name>nutz</filter-name>
  14. <url-pattern>/*</url-pattern>
  15. <!-- ForwardView需要下面的配置 @Ok("->:/xxx/yyy/zzz") -->
  16. <dispatcher>REQUEST</dispatcher>
  17. <dispatcher>FORWARD</dispatcher>
  18. <dispatcher>INCLUDE</dispatcher>
  19. </filter-mapping>
  20. <welcome-file-list>
  21. <welcome-file>index.html</welcome-file>
  22. <welcome-file>index.htm</welcome-file>
  23. <welcome-file>index.jsp</welcome-file>
  24. <welcome-file>default.html</welcome-file>
  25. <welcome-file>default.htm</welcome-file>
  26. <welcome-file>default.jsp</welcome-file>
  27. </welcome-file-list>
  28. </web-app>

手册关联(选修)