尝试用Filter 实现跨域时,提示is not assignable to 'javax

实现跨域时,配置 web.xml时提示:

CORSFilter is not a concrete class

CORSFilter is not assignable to 'javax,servlet.Filter'

是什么原因?


-----------------------------web.xml---------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"


     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

     version="3.1">

<!--display-name 显示名称-->

<display-name>wechat-baggio</display-name>

<servlet>

    <servlet-name>WxServlet</servlet-name>

    <!--<servlet-class>boilerWeChat.servlet.WxServlet</servlet-class>-->

    <servlet-class>boilerWeChat.servlet.WxServlet</servlet-class>

    <!--自动启动-->

    <load-on-startup>1</load-on-startup>

</servlet>

<!-- url-pattern中配置的/WxServlet用于指定该Servlet的访问路径 -->

<servlet-mapping>

    <servlet-name>WxServlet</servlet-name>

    <url-pattern>/WxServlet</url-pattern>

</servlet-mapping>


<!--<welcome-file-list>-->

    <!--<welcome-file></welcome-file>-->

<!--</welcome-file-list>-->

**<filter>

    <filter-name>CORSFilter</filter-name>

    <filter-class>boilerWeChat.servlet.CORSFilter</filter-class>

    /**这里提示错误:boilerWeChat.servlet.CORSFilter is not a concrete class;boilerWeChat.servlet.CORSFilteris not assignable to 'javax,servlet.Filter'**/

    <init-param>

        <param-name>charset</param-name>

        <param-value>UTF-8</param-value>

    </init-param>

</filter>

<filter-mapping>

    <filter-name>CORSFilter</filter-name>

    <url-pattern>/*</url-pattern>

</filter-mapping>**

</web-app>




Helenr
浏览 1665回答 1
1回答

吃鸡游戏

public abstract class CORSFilter implements Filter 你使用了抽象类去实现Filter肯定不行,请将abstract去掉
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java