zoukankan      html  css  js  c++  java
  • Struts2标签问题-using Struts tags without the associat

    Xml代码  收藏代码
    1. <filter-mapping>  
    2.     <filter-name>struts2</filter-name>  
    3.     <url-pattern>*.jsp</url-pattern>  
    4. </filter-mapping>  

         最近使用struts,在使用标签的时候,出现了这样一个问题。

         原本使用标签,引用方法是默认配置:

         web.xml:

         

    Java代码  收藏代码
    1. <filter>  
    2.   <filter-name>struts2</filter-name>  
    3.     <filter-class>  
    4.        org.apache.struts2.dispatcher.FilterDispatcher  
    5.     </filter-class>  
    6. </filter>  
    7.   
    8. <filter-mapping>  
    9.     <filter-name>struts2</filter-name>  
    10.     <url-pattern>/*</url-pattern>  
    11. </filter-mapping>  

         在页面中引用:

      

    Java代码  收藏代码
    1. <%@ taglib prefix="s" uri="/struts-tags"%>  

        由于在使用的web应用中一些特殊应用的关系,web.xml的配置改为:

    Java代码  收藏代码
    1. <filter>  
    2.   <filter-name>struts2</filter-name>  
    3.     <filter-class>  
    4.        org.apache.struts2.dispatcher.FilterDispatcher  
    5.     </filter-class>  
    6. </filter>  
    Java代码  收藏代码
    1. <taglib>  
    2.   <taglib-uri>struts-tags</taglib-uri>  
    3.   <taglib-location>/WEB-INF/struts2-core-2.0.11.jar</taglib-location>  
    4.  </taglib>  
    5.   
    6. <filter-mapping>  
    7.     <filter-name>struts2</filter-name>  
    8.     <url-pattern>/*.action</url-pattern>  
    9. </filter-mapping>  

        让sturts过滤器只接受后缀名为action的请求,并把struts标签配置到web.xml文件。

      

        但在使用中,直接访问index.jsp,出现异常:

       

    Java代码  收藏代码
    1. The Struts dispatcher cannot be found.  This is usually caused by using Struts tags without the associated filter. Strut  
    2. s tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher n  
    3. eeded for this tag. - [unknown location]  

       在struts2中不能直接使用jsp,引用struts2的标签么?是否有解决的方法?希望大家能不吝赐教!

       找到解决方法了,其实只要再加一个过滤设置就可以了:

      

    Java代码  收藏代码
    1. <filter-mapping>  
    2.     <filter-name>struts2</filter-name>  
    3.     <url-pattern>*.jsp</url-pattern>  
    4. </filter-mapping>  
    Java代码  收藏代码
    1. <filter-mapping>  
    2.     <filter-name>struts2</filter-name>  
    3.     <url-pattern>/struts/*</url-pattern>  
    4. </filter-mapping>  
  • 相关阅读:
    Mybatis配置文件中Insert 元素标签添加配置有哪些呢?
    Mybatis配置文件中Select元素标签输入参数有多少种输入方式呢?
    Mybatis配置文件如何进行配置呢?
    Centos安装 Apache Benchmark
    本地连接阿里云上的mysql centos
    python 导出项目需要的库
    Nginx报错:nginx: [error] OpenEvent("Global gx_reload_14944") failed (2: The system cannot find the file specified)
    windows安装uwsgi报错 AttributeError: module 'os' has no attribute 'uname'
    P3346 [ZJOI2015]诸神眷顾的幻想乡(广义后缀自动机)
    P6139 【模板】广义后缀自动机(广义 SAM)
  • 原文地址:https://www.cnblogs.com/chenzhao/p/2304601.html
Copyright © 2011-2022 走看看