Jetty 9删除了URI片段

时间:2014-10-01 12:23:25

标签: jetty web.xml form-authentication uri-fragment

我想要使用web.xml中的安全约束来保护WebApplication。

这里是来自web.xml

的loginConfig
<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>MyUserRealm</realm-name>
    <form-login-config>
        <form-login-page>/login/login.html</form-login-page>
        <form-error-page>/login/login-error.html</form-error-page>
    </form-login-config>
</login-config>

这里有安全限制:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Public</web-resource-name>
        <url-pattern>/login/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Private</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>**</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>

这很好用,我会被重定向到所需的login.html网站,在那里我可以正确地验证自己。 login.html看起来像这样:

<form method="post" action="/j_security_check" id="loginform">
    <input class="login" value="" name="j_username" maxlength="25" type="text" placeholder="Username" required/>
    <input class="login" value="" name="j_password" maxlength="25" type="password" placeholder="Password" required/>
    <input name="submit" type="submit" value="Login" />
</form>

我现在的问题是,我用于原始URL的URI片段被转发到登录站点,但是在身份验证之后没有包含回原始站点。因此我丢失了我想要在WebApp中检查的所有片段和参数。

有人知道为什么会删除URI片段吗?

1 个答案:

答案 0 :(得分:0)

URI片段不会被浏览器发送到服务器。

查看有关该主题的过去答案:https://stackoverflow.com/a/13503246/775715