我认为这是一个奇怪的问题。
使用与servlet相同的映射,一个url工作,另一个不工作:
<servlet-mapping>
<servlet-name>UL_Admin</servlet-name>
<url-pattern>/universal_listings_administration/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Create_New_Site</servlet-name>
<url-pattern>/universal_listings_administration/sites/new_site/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Create_New_Site</servlet-name>
<url_pattern>/universal_listings_administration/sites/delete_site/*</url_pattern>
</servlet-mapping>
Create_New_Site适用于/ universal_listings_administration / sites / new_site / *,但不适用于/ universal_listings_administration / sites / delete_site / *
当进入/ universal_listings_administration / sites / delete_site / *时,网站只需转到UL_Admin !!!
我已经更改了网址的顺序,但获得了相同的结果。我在不同的浏览器上试过这个,认为它可能是一个缓存问题,但每次都得到相同的结果。
有没有人知道这里发生了什么?
我认为唯一可能的另一件事是我的过滤器还是什么?我看了一眼,但过滤器似乎一切正常。无论如何,这是我在web.xml中的安全性和过滤器设置
<security-constraint>
<web-resource-collection>
<url-pattern>/universal_listings_administration/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<url-pattern>/jsps/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<url-pattern>/stylesheets/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<!-- Filters -->
<filter>
<!-- This filter defines all of the URIs on the site, to ensure easy to update URIs -->
<!-- All URIs defined here will be added to the request's Attributes -->
<!-- The URIs follow naming convention uri-name or uri-admin-name -->
<!-- For simplicity sake, do this only for client URIs (internal can be covered by eclipse!) -->
<filter-name>UriSettingFilter</filter-name>
<filter-class>nz.co.unilistings.control.UriAttributeSettingFilter</filter-class>
<init-param>
<param-name>uri-admin-portal</param-name>
<param-value>/universal_listings_administration/</param-value>
</init-param>
<init-param>
<param-name>uri-admin-new-site</param-name>
<param-value>/universal_listings_administration/sites/new_site/</param-value>
</init-param>
<init-param>
<param-name>uri-admin-delete-site</param-name>
<param-value>/universal_listings_administration/sites/delete_site/</param-value>
</init-param>
</filter>
<filter>
<filter-name>SubdomainFilter</filter-name>
<filter-class>nz.co.unilistings.control.SubdomainFilter</filter-class>
<init-param>
<description>Any subdomain with this value will go to the parent site</description>
<param-name>parent_site_subdomain</param-name>
<param-value>www</param-value>
</init-param>
<init-param>
<description>The URL of the parent site (where people can register)</description>
<param-name>parent_url</param-name>
<param-value>http://www.example.com:8888</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SubdomainFilter</filter-name>
<servlet-name>*</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>UriSettingFilter</filter-name>
<servlet-name>*</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
更新:
我做了一些调试,我确定我要去正确的URL,(从web.xml复制,粘贴),这是我在请求到达第一个过滤器时得到的(比较create_site和delete_site :
create_site: http://www.example.com:8888/universal_listings_administration/sites/new_site/ _pathInfo:“/” _requestURI:“/ universal_listings_administration / sites / new_site /” _servletPath:“/ universal_listings_administration / sites / new_site” _uri:“/ universal_listings_administration / sites / new_site /”
delete_site: http://www.example.com:8888/universal_listings_administration/sites/delete_site/ _pathInfo:“/ sites / delete_site /” _requestURI:“/ universal_listings_administration / sites / delete_site /” _servletPath:“/ universal_listings_administration” _uri:“/ universal_listings_administration / sites / delete_site /”
我想我现在必须弄明白为什么_pathInfo和_servletPath完全不同......
答案 0 :(得分:0)
映射看起来很好。这些症状至少表明实际 URL错误或某些过滤器或servlet在到达servlet之前或之后更改了请求/响应目标。
如果没有调试/记录所有servlet和过滤器来跟踪整个代码中HttpServletRequest
实例的执行路径,这个问题很难确定。由于我们无法访问您的代码/环境来重现问题,因此完成此任务完全取决于您。
答案 1 :(得分:0)
我认为我的web.xml中的url-mapping肯定有问题。必须非常微妙,只能通过复制和粘贴另一个servlet映射并更改URL来修复。
可能的原因:使用德语键盘,并在英语和德语之间切换???
答案 2 :(得分:0)
看起来像一个简单的拼写错误,应该是<url-pattern>
,而不是<url_pattern>