【问题标题】:JSF calling method with non String parameters带有非字符串参数的 JSF 调用方法
【发布时间】:2014-03-23 04:19:16
【问题描述】:

我的 JSF 中有:

<h:commandButton value="Add to Cart"
    rendered="#{movieDisplayController.movie.available != 0}"
    action="#{cartController.addMovie(movieDisplayController.movie, '2')}">
</h:commandButton>

action 在 Eclipse (kepler JEE) 中带有红色下划线并显示:

方法必须有签名“String method(), String method(), String method(String), String 方法(字符串,字符串),字符串方法(字符串,字符串,字符串),字符串方法(字符串,字符串,字符串, 字符串),字符串方法(字符串,字符串,字符串,字符串,字符串),字符串方法(字符串,字符串,字符串, 字符串,字符串,字符串),字符串方法(字符串,字符串,字符串,字符串,字符串,字符串,字符串),字符串 方法(字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串),字符串方法(字符串,字符串, 字符串,字符串,字符串,字符串,字符串,字符串,字符串),字符串方法(字符串,字符串,字符串,字符串,字符串, 字符串,字符串,字符串,字符串,字符串),字符串方法(字符串,字符串,字符串,字符串,字符串,字符串,字符串, 字符串,字符串,字符串,字符串),字符串方法(字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串, 字符串,字符串,字符串,字符串),字符串方法(字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串, 字符串,字符串,字符串,字符串,字符串),字符串方法(字符串,字符串,字符串,字符串,字符串,字符串,字符串, 字符串,字符串,字符串,字符串,字符串,字符串,字符串),字符串方法(字符串,字符串,字符串,字符串,字符串, 字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串),字符串方法(字符串,字符串, 字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串), 字符串方法(字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串, 字符串,字符串,字符串,字符串,字符串),字符串方法(字符串,字符串,字符串,字符串,字符串,字符串,字符串, 字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串),字符串方法(字符串, 字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串,字符串, String, String, String, String)”,但有签名“String method(Movie, Integer)”

方法定义为:

public String addMovie(Movie movie, Integer quantity) {
    //...
    return null;
}

当我按下按钮时它运行正常 - 是 Eclipse 中的错误还是我做错了什么?

编辑:也可以正确运行:

action="#{cartController.addMovie(movieDisplayController.movie, 2)}">

action="#{cartController.addMovie(movieDisplayController.movie,
    movieDisplayController.quantity)}">

太棒了reported

【问题讨论】:

标签: eclipse jsf facelets jsf-2.2 glassfish-4


【解决方案1】:

Passing parameter to JSF action中引用@BalusC

当您使用根声明定义 Servlet 3.0 的 web.xml 以 Servlet 3.0 容器(Tomcat 7、Glassfish 3、JBoss AS 6 等)为目标时,您应该能够直接将参数传递到EL 2.2(Servlet 3.0 的一部分)支持的操作方法。

你的方法应该是完全正确的,我猜这是eclipse开普勒的一个bug。

【讨论】:

    猜你喜欢
    • 2016-06-15
    • 1970-01-01
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    • 2012-01-27
    • 1970-01-01
    • 2011-07-13
    • 2019-06-08
    相关资源
    最近更新 更多