Hallo Zusammen,
ich arbeite an einem Tutorial in JSP/JSF, aber leider kann die erstellte JSP-Seite nicht aufgerufen werden. Bekomme diese Fehlermeldung:
HTTP Status 404 - /HelloWorldJSF/AddUser.jsf
--------------------------------------------------------------------------------
type Status report
message /HelloWorldJSF/AddUser.jsf
description The requested resource (/HelloWorldJSF/AddUser.jsf) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/7.0.6
Den Code habe ich 1 zu 1 vom Tutorial übernommen und zwar folgendermaßen:
UserBean.java
AddUser.jsp
ListUser.jsp
faces-config.xml
web.xml
Würde mich auf Tipps superfreuen.
mfg
ich arbeite an einem Tutorial in JSP/JSF, aber leider kann die erstellte JSP-Seite nicht aufgerufen werden. Bekomme diese Fehlermeldung:
HTTP Status 404 - /HelloWorldJSF/AddUser.jsf
--------------------------------------------------------------------------------
type Status report
message /HelloWorldJSF/AddUser.jsf
description The requested resource (/HelloWorldJSF/AddUser.jsf) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/7.0.6
Den Code habe ich 1 zu 1 vom Tutorial übernommen und zwar folgendermaßen:
UserBean.java
Code:
package net.viralpatel.jsf.helloworld;
public class UserBean {
private int id;
private String name;
//Action method to add user
public String addUser() {
return "success";
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
AddUser.jsp
Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Add New User Form</title>
</head>
<body>
<f:view>
<p><h:message id="errors" for="User_ID" style="color:red" /></p>
<h:form>
<h:panelGrid border="1" columns="2">
<h:outputText value="ID">
</h:outputText>
<h:inputText id="User_ID" value="#{userBean.id}" required="true">
<f:validateLongRange minimum="1" maximum="500" />
</h:inputText>
<h:outputText value="Name">
</h:outputText>
<h:inputText value="#{userBean.name}">
</h:inputText>
<h:commandButton action="#{userBean.addUser}" value="Add Customer">
</h:commandButton>
</h:panelGrid>
</h:form>
</f:view>
</body>
</html>
ListUser.jsp
Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>List of Users</title>
</head>
<body>
<f:view>
<h:form>
<h:outputText value="User #{userBean.name} is added successfully.">
</h:outputText>
</h:form>
</f:view>
</body>
</html>
faces-config.xml
Code:
<?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">
<managed-bean>
<managed-bean-name>userBean</managed-bean-name>
<managed-bean-class>net.viralpatel.jsf.helloworld.UserBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<display-name>AddUser</display-name>
<from-view-id>/AddUser.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/ListUser.jsp</to-view-id>
</navigation-case>
</navigation-rule> </faces-config>
web.xml
Code:
<?xml version="1.0" encoding="ASCII"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>HelloWorldJSF</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name> //Servlet rot unterstrichen
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name> //Servlet rot unterstrichen
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
Würde mich auf Tipps superfreuen.
mfg