我一直在从事Spring项目。我想用localhost:8080 / app / main / something而不是localhost:8080 / app / main.htm?type = something编写URL。
或类似localhost:8080 / app / employee / input之类的东西,而不是localhost:8080 / employee.htm?type = input,但到目前为止,URL保持不变。有人可以帮我吗?

这是我的web.xml

        <filter>
            <filter-name>UrlRewriteFilter</filter-name>
            <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
            <init-param>

                <param-name>logLevel</param-name>
                <param-value>DEBUG</param-value>
            </init-param>
        </filter>

        <filter-mapping>
            <filter-name>UrlRewriteFilter</filter-name>
            <url-pattern>/*</url-pattern>
            <dispatcher>REQUEST</dispatcher>
            <dispatcher>FORWARD</dispatcher>
        </filter-mapping>



      <servlet-mapping>
    <servlet-name>verse</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>


这是我的urlrewrite.xml

 <rule>
<from>^/main.htm?type=([a-z]+)$</from>
<to type="redirect">/main/something/</to>
 </rule>

 <rule>
<from>^/inputregion.htm$</from>
<to type="redirect">/main/region/input</to>
 </rule>


我在servlet中的viewResolver:

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
            <property name="prefix" value="/WEB-INF/jsp/"></property>
            <property name="suffix" value=".jsp"></property>
        </bean>

最佳答案

弄清楚了

<outbound-rule enabled="true">
        <from>^/main\.htm$</from>
        <to type="redirect">/dashboard/</to>

     </outbound-rule>



    <rule enabled="true">
        <from>/dashboard/</from>
        <to>/main.htm</to>
    </rule>

09-26 11:17