我有网络应用程序,我想部署到weblogic,我添加了UrlRewriteFilter
<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>
我还定义了以下规则:
<rule>
<note>the context root should be redirected by appending a / to the path</note>
<from>%{context-path}</from>
<to type="redirect">%{context-path}/</to>
</rule>
我想以与Tomcat中可能类似的方式重定向Weblogic中的上下文根。
有关详细信息,请参阅Redirect context root in Weblogic
当我部署应用程序并尝试访问http://localhost:7001/my-application时,我得到:
org.tuckey.web.filters.urlrewrite.Conf DEBUG: now initialising conf
org.tuckey.web.filters.urlrewrite.NormalRule ERROR: Rule Rule 0 had error: from (%{context-path}) is an invalid expression - java.util.regex.PatternSyntaxException: Illegal repetition near index 0
%{context-path}
^
org.tuckey.web.filters.urlrewrite.RuleBase ERROR: from (%{context-path}) is an invalid expression - java.util.regex.PatternSyntaxException: Illegal repetition near index 0
%{context-path}
^
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: loaded rule Rule 0 (%{context-path}, %{context-path}/ 0)
org.tuckey.web.filters.urlrewrite.NormalRule DEBUG: failed to load rule
org.tuckey.web.filters.urlrewrite.Conf DEBUG: conf status false
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: inited with 1 rules
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: conf is NOT ok
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter ERROR: Conf failed to load
我也理解我的过滤器有<url-pattern>/*</url-pattern>
,因此它会捕获两个网址(带斜线和不带斜线)
是否有可能实现我对http://www.tuckey.org/urlrewrite/
所描述的内容如果是,怎么样?
如果不是,为什么?
答案 0 :(得分:0)
您的 <from>
标记不正确。希望这会有所帮助
如果 context-path
"myApp"
<rule>
<from>^(.*)$</from>
<to type="redirect" context="myApp">$1/</to>
</rule>
如果 context-path
""
,即 empty
,那么您不需要编写任何规则以将请求转发到上下文,因为默认情况下请求将转发到默认上下文