Glassfish Realm Netbeans 8.0.2 Glassfish 4.1

时间:2015-01-22 16:10:16

标签: java-ee netbeans glassfish

我正在尝试保护对已登录用户访问JSP的Web应用程序我决定使用glassfish领域我已经从互联网上完成了很多教程,但问题总是一样的。

我无法登录,是因为大多数教程都使用glassfish 3.x吗?

我在这里看过类似的帖子,但没有人给出答案

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <security-constraint>
        <display-name>admin</display-name>
        <web-resource-collection>
            <web-resource-name>prywatne</web-resource-name>
            <description/>
            <url-pattern>/prywatne/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>PUT</http-method>
            <http-method>HEAD</http-method>
            <http-method>POST</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
            <http-method>DELETE</http-method>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>annRealm</realm-name>
    </login-config>
    <security-role>
        <description/>
        <role-name>admin</role-name>
    </security-role>
    <security-role>
        <description/>
        <role-name>user</role-name>
    </security-role>
</web-app>

2 个答案:

答案 0 :(得分:0)

看起来问题是您没有在FacesServlet中设置web.xml

web.xml中添加以下内容:

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>loginForm.xhtml</welcome-file>
</welcome-file-list>

如果需要,您还可以更改欢迎文件

另见:

答案 1 :(得分:0)

通过此视频https://www.youtube.com/watch?v=1xsU6juUZd0

排序问题

我没有使用加密,所以我没有。无论如何问题是在用户表和组表的领域只有表名是不够的但模式databasename.tablename帮助