gpt4 book ai didi

java - urlrewrite.xml 似乎不起作用

转载 作者:行者123 更新时间:2023-11-30 09:43:56 27 4
gpt4 key购买 nike

我一直在从事 Spring 项目。我希望我的 URL 写在 localhost:8080/app/main/something 而不是 localhost:8080/app/main.htm?type=something。或者可能类似于 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>

关于java - urlrewrite.xml 似乎不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8146827/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com