我可以将form-login-page html放在一个webapp库中吗?

时间:2011-03-02 06:02:41

标签: java login weblogic web.xml

我正在尝试使用登录页面身份验证创建应用。为此,我将<form-login-page>添加到web.xml中(如下所示)。

我查看了logon.html和logonerror.html,并将它们与.war webapp文件一起添加为库。 (在WEB-INF / lib / logon.jar下)。

但是当我部署应用程序时,我收到ERROR 404,找不到logon.html错误。 任何指针为什么?我不能将登录文件(htmls,js,css文件)保存在库中吗?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee">
<filter>
    <filter-name>MyFilter</filter-name>
    <filter-class>MyFilter</filter-class> 
     <init-param>
        <param-name>Domainname</param-name>
        <param-value></param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>MyFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping> 

<security-constraint>
    <web-resource-collection>
        <web-resource-name>SecuredResources</web-resource-name>
        <url-pattern>/*</url-pattern>       
    </web-resource-collection>
    <auth-constraint>
        <role-name>Default_Role</role-name>
    </auth-constraint>
        <user-data-constraint>             
         <transport-guarantee>CONF</transport-guarantee>
    </user-data-constraint>
</security-constraint>

<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
      <form-login-page>/logon.html</form-login-page>
      <form-error-page>/logonerror.html</form-error-page>
    </form-login-config>
  </login-config>  

   <security-role>
    <role-name>Default_Role</role-name>
  </security-role>

</web-app>

2 个答案:

答案 0 :(得分:2)

我的理解是WAR只会公开其自己的根文件结构中包含的资源。因此,在this question的答案中提到了解决方法(weblets,Maven配置)。你可以创建一个自定义构建脚本,将logon.jar的内容解压缩到你的WAR中,但我绝对不会推荐那种黑客。通过更多关于为什么的信息,您可以提供更好的方法。

答案 1 :(得分:0)

据我所知,html文件应放在WAR而不是JAR中,因为它们是Web资源。 JAR文件应该只包含使用类加载机制由Web组件(例如Servlet,JSP)查找的类/资源。