tomcat 301很明显不提供此功能应该更正确的叫做JAVA301,适合要做友好SEO的朋友
不多做解释,做SEO的话JAVA基本选urlrewrite,所以下面讲的是如何结合urlrewrite做域名跳转。对于301此文章基本是精华贴了。下面直接贴代码。
注意下面的condition不是指你要拦截什么域名而是与你要跳转的域名相对应,比如jb51.net跳www.jb51.net 那就在condition填www.jb51.net
第一种urlrewrite配置:
<urlrewrite>
    <rule>
        <name>seo redirect</name>
        <condition name="host" operator="notequal">^www.jb51.net</condition>
        <from>^/(.*)</from>
        <to type="permanent-redirect" last="true">https://www.jb51.net/$1</to>
    </rule>
</urlrewrite>
第二种urlrewrite配置:
<urlrewrite>
    <rule>
        <name>seo redirect</name>
        <condition name="host" operator="notequal">^www.jb51.net</condition>
        <condition name="host" operator="notequal">^localhost</condition>
        <from>^/(.*)</from>
        <to type="permanent-redirect" last="true">https://www.jb51.net/$1</to>
    </rule>
</urlrewrite>