官方文檔:https://tomcat.apache.org/tomcat-7.0-doc/config/filter.html

<專案路徑>/WEB-INF/web.xml

以下供參考:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1"
    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">


<!-- session-config ==================================================== -->

<session-config>
<session-timeout>
30
</session-timeout>
</session-config>

<!-- error-page ======================================================== -->

<error-page>
<error-code>404</error-code>
<location>/index.html</location>
</error-page>

<!-- filter ============================================================ -->

<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>http://localhost:8080</param-value>
<param-value>http://127.0.0.1:8080</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 黃彥霖 的頭像
    黃彥霖

    彥霖 實驗筆記

    黃彥霖 發表在 痞客邦 留言(0) 人氣()