小编use*_*352的帖子

如何将LocalDate转换为Instant?

我使用Java 8的新DateTime API.

如何将LocalDate转换为Instant?我得到一个例外

LocalDate date = LocalDate.of(2012, 2, 2);
Instant instant = Instant.from(date);
Run Code Online (Sandbox Code Playgroud)

而且我不明白为什么.

java datetime java-8 java-time

89
推荐指数
2
解决办法
6万
查看次数

如何在POST请求后重定向到同一页面

如何重定向到同一页面(我不知道页面;重定向是在几个页面共享的菜单中完成的)?

我试过了

return "?faces-redirect=true";
Run Code Online (Sandbox Code Playgroud)

在操作方法的最后,但我收到一条错误消息,因为无法找到"?faces-redirect = true"的导航案例.

在此先感谢您的帮助.

jsf-2

9
推荐指数
1
解决办法
4972
查看次数

Jakarta EE 9 的 JSF 页面中“h”、“f”等的命名空间是什么?

我尝试过xmlns:h="jakarta.faces.html"xmlns:h="http://jakarta.faces.html"xmlns:h="https://jakarta.faces.html"和其他类似的字符串,但似乎没有任何效果。

jsf jakarta-ee

9
推荐指数
1
解决办法
3453
查看次数

发现在有状态的ejb扩展中找到的JPA实体不受管理

我认为em.find找到的实体是由em自动管理的,甚至是一个事务,但下面的这个类似乎表明相反.我错了还是班上的错误是什么?

@Stateful
@TransactionAttribute(NOT_SUPPORTED)
public class CustomerGateway {

  @PersistenceContext(unitName = "customersPU", type = EXTENDED)
  private EntityManager em;
  private Customer customer;

  public Customer find(Long id) {
    // customer is not managed!
    this.customer = em.find(Customer.class, id);
    // Print false!
    System.out.println("Method find: " + em.contains(customer));
    // Print false too (2 is the id of an entity)!
    System.out.println("Method find: " + em.contains(em.find(Customer.class, 2L));
    // A workaround
    customer = em.merge(customer);
    // Print true.
    System.out.println("Method find after merge: " + em.contains(customer));
    return this.customer;
  }
Run Code Online (Sandbox Code Playgroud)

编辑1:实体的代码

@Entity
@NamedQuery(name …
Run Code Online (Sandbox Code Playgroud)

java ejb jpa stateful-session-bean

6
推荐指数
1
解决办法
1513
查看次数

JSF 2.0:如何在使用HttpServletRequest.login后重定向到受保护的页面

我正在尝试使用基于表单的身份验证的HttpServletRequest.login.

一切都好(容器告诉登录/密码是否良好),除了在用户输入登录后,我不知道如何将用户重定向到他要求的受保护页面(重新显示登录表单).怎么做?

在此先感谢您的帮助.

代码:

web.xml中:

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>security</realm-name>
    <form-login-config>
        <form-login-page>/faces/loginwithlogin.xhtml</form-login-page>
        <form-error-page>/faces/noaut.xhtml</form-error-page>
    </form-login-config>
</login-config>
Run Code Online (Sandbox Code Playgroud)

页面loginwithlogin.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Authentication</title>
    </h:head>
    <h:body>
        <h:form>
            Login :
            <h:inputText value="#{login.login}" required="true" />
            <p/>
            Mot de passe :
            <h:inputSecret value="#{login.password}" required="true" />
            <p/>
            <h:commandButton value="Connexion" action="#{login.submit}">
                 <f:ajax execute="@form" render="@form" />
            </h:commandButton>
            <h:messages />
        </h:form>
    </h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

更新:没有Ajax它不起作用.

支持豆:

@Named
@SessionScoped
public class Login implements Serializable {
  private String login;
  private String password;
  // getters and setters 
  ...

  public void submit() {
    FacesContext context = …
Run Code Online (Sandbox Code Playgroud)

java authentication jsf-2

5
推荐指数
1
解决办法
3420
查看次数

glassfish-resources.xml 被 NetBeans 8.0.1 忽略了吗?

我刚刚将 NetBeans 8.0.1 和 GlassFish 4.1 用于 2 个与 NetBeans 8.0 和 GlassFish 4.0 配合良好的旧项目。

现在(使用 NetBeans 8.0.1)我在项目部署期间收到错误“tInvalid resource : jdbc/nameOfTheSource__pm”。

JDBC 资源和连接池由 glassfish-resources.xml 定义(当我使用“创建持久单元”和“新数据源”选项定义新实体时由 NetBeans 生成)。

如果我通过 asadmin 的命令 add-resource 直接使用 glassfish-resources,则在服务器上,一切正常:创建了连接池和 JDBC 资源。所以问题不是来自这个文件。

就好像在部署过程中忽略了 glassfish-resources.xml。

有人有同样的问题(并有解释)吗?

我的环境:NetBeans 8.0.1、GlassFish 4.1、Java DB 10.10.1.2 - (1495037)(来自 Java 8.0)。

相关问题:在部署过程中如何使用 glassfish-resources?它不包含在 EAR 或 WAR 文件中。

在此先感谢您的帮助。

netbeans glassfish jakarta-ee

5
推荐指数
1
解决办法
2538
查看次数