相关疑难解决方法(0)

我可以从<filter-mapping>中的<url-pattern>中排除一些具体的URL吗?

我想要一些混凝土过滤器应用于除一个混凝土之外的所有网址(即/*除了/specialpath).

有可能这样做吗?


示例代码:

<filter>
    <filter-name>SomeFilter</filter-name>
    <filter-class>org.somproject.AFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>SomeFilter</filter-name>
    <url-pattern>/*</url-pattern>   <!-- the question is: how to modify this line?  -->
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
Run Code Online (Sandbox Code Playgroud)

java servlets servlet-filters

121
推荐指数
3
解决办法
17万
查看次数

如何从tomcat提供静态内容

我有一个包含许多静态文件的目录(*.png,*.css等).
我想(也许是错误的)只是在我的应用程序的WEB-INF文件中创建一个目录就足够了,我只能通过名称引用它们来访问这些文件:
Ex:

   <link rel="stylesheet" href="/static/styles.css" type="text/css">
Run Code Online (Sandbox Code Playgroud)

我的目录结构如下:

+WEB-INF
   |
   +---static
       |
       +--styles.css
       +--header.png
Run Code Online (Sandbox Code Playgroud)

我的web.xml如下

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>myapp</display-name>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:com/example/myapp/spring/applicationContext.xml</param-value>
    </context-param>

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <listener>
        <listener-class>
            com.example.myapp.ContextListener
        </listener-class>
    </listener>

    <!--  
        There are three means to configure Wickets configuration mode and they are
        tested in the order given. 
        1) A system property: -Dwicket.configuration
        2) servlet specific <init-param>
        3) context specific <context-param>
        The value might be either "development" (reloading when templates change) …
Run Code Online (Sandbox Code Playgroud)

java tomcat

24
推荐指数
2
解决办法
5万
查看次数

标签 统计

java ×2

servlet-filters ×1

servlets ×1

tomcat ×1