java - 命令按钮在 JSP 文件中不可见

标签 java eclipse jsf weblogic

我刚刚读过类似的帖子。我已经改正了我的错误。但不起作用...

我正在使用 eclipse + weblogic 进行编程。

我想我也没有解释。

我需要它有效。谢谢。

index.jsp

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Videoclub</title>
</head>
<body>
<f:view>
Index
<h:commandButton type="submit" value="Ir a pagina 2" action="IndexToPagina2" ></h:commandButton>
<h:form>
nombre
<h:commandButton type="submit" value="Ir a pagina 2" action="IndexToPagina2" ></h:commandButton>

</h:form>

</f:view>
</body>
</html>

pag2.jsp

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<f:view>
pag2

</f:view>
</body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Videoclub</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <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>*.jsf</url-pattern>
  </servlet-mapping>
</web-app>

faces-config.xml

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

<faces-config 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-facesconfig_2_0.xsd"
    version="2.0">
    <application>
        <message-bundle>resources.application</message-bundle>
        <locale-config>
            <default-locale>en</default-locale>
        </locale-config>
    </application>

    <navigation-rule>
        <from-view-id>/index.jsp</from-view-id>
        <navigation-case>
            <from-outcome>IndexToPagina2</from-outcome>
            <to-view-id>/pag2.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>

</faces-config>

最佳答案

<h:commandButton type="submit" value="Ir a pagina 2" action="IndexToPagina2" >

看来您正在使用 JSF。您需要导入所需的标签库。

示例:

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

阅读more here .

关于java - 命令按钮在 JSP 文件中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22721814/

相关文章:

java - 了解 Scala 中的 ArrayBuffer

java - 如何通过 Intent.ACTION_VIEW 从​​ url 播放 .m4a 音频?

java - 创建新的可打包对象的正确方法

eclipse - 如何使用 Eclipse 代码样式在 wordpress 中突出显示我的代码

java - 由于 DDMS post create init,Eclipse 挂起

eclipse无法自动生成makefile

javascript - JSF。如何将JavaScript函数的值设置为Bean的字段?

java - 查找在 Windows 上的 Android Studio 中不起作用的 id 用法

java - Netbeans 7.2.1 可视化 Web 编辑器

jsf - 当我导航时,JSF 生命周期是否会重新应用于结果 Facelet?