Jakarta ee Glassfish王国Netbeans 8.0.2 Glassfish 4.1

Jakarta ee Glassfish王国Netbeans 8.0.2 Glassfish 4.1,jakarta-ee,netbeans,glassfish,Jakarta Ee,Netbeans,Glassfish,我正在开发一个web应用程序,试图保护登录用户对JSP的访问。我决定使用glassfish realms。我在internet上做了很多教程,但问题总是一样的 我无法登录,是不是因为大多数教程都使用glassfish 3.x 我在这里看到过类似的帖子,但没有人给出答案 <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xm

我正在开发一个web应用程序,试图保护登录用户对JSP的访问。我决定使用glassfish realms。我在internet上做了很多教程,但问题总是一样的

我无法登录,是不是因为大多数教程都使用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>

30
管理
普赖瓦特
/普赖瓦特/*
收到
放
头
邮递
选择权
查出
删去
管理
基本的
安纳里姆
管理
使用者

问题似乎是您没有在
web.xml
中设置
FacesServlet

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>

Facesservlet
javax.faces.webapp.FacesServlet
1.
Facesservlet
*.xhtml
loginForm.xhtml
如果需要,还可以更改欢迎文件

另请参见:


由于此视频,问题得以解决


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

您甚至没有问任何问题…可能出现什么问题?所有内容都与少数类似的教程完全相同,它不会登录到唯一不同的是glasfish和NetBean版本。在大多数情况下,问题出现在监视器前面(OSI级别8)。当你不详细描述的时候,没人能猜到你到底尝试了什么……我还不能发布图片来展示一切。这个OSI 8级怎么样?我所做的和本教程中的完全一样-简单测试完成数据库(两个表一个用户(用户名密码)第二个角色(用户名,角色)完成jdbc池,资源,在web.xml和sun-web.xml完成文件夹“protected”中完成一切这个文件夹中有一个html文件,在安全建设中是url模式,我得到了所有GRUP等推送运行文件(表单保护文件夹)登录(基本,默认)窗口显示在webrowser中,所以我输入用户名和密码,就像我在数据库中得到的一样,什么都没有请编辑问题并添加你的
web.xml
(文本,您不需要发布图像)它必须包含jsf吗?我只是看了一本关于java_ee_6_development_和_netbeans_7的书,jsf没有什么,但奇怪的是,即使是这本书中的示例也不起作用是的,如果您像在教程中那样编写XHTML代码,这就是jsf,您需要
web.xml
中的条目才能使用它“启用"是的,但你不想使用JSP。这是一种过时的技术,不应该在新项目中使用。看起来你忘了为Glassfish安装MySQL驱动程序。我已经完成了驱动程序连接,现在可以工作了。我已经做了另一个测试,当我使用realmname文件时,它可以工作,但当我使用自己的领域时,它会一直要求登录,即使p但数据库(用户名和密码)Glasfish日志中对此的确切内容是“严重:jdbcream.invaliduserreason警告:WEB9102:Web登录失败:com.sun.enterprise.security.auth.Login.common.LoginException:Login失败:安全异常”这是什么原因?在领域i中,将密码加密算法设置为“无”