Boa tarde pessoal, estou a varios dias tentando rodar minha aplicação ‘Ola Mundo’ com Strust.Estou Usando Netbeans 5.5 com tomcat embutido.Peguei um exemplo na net, fiz igual ao solicitado, mas quando vou rodar aparece o error: 404.Gostaria de alguem me ajudasse.Estou ansioso para aprender struts.A estrutura do meu projeto é composto assim:
2 paginas = index.jsp e helloWorld.jsp
coloquei todas os arquivos .jar na pasta WEB-INF\LIB
pacote : struts2.actions, local onde esta minha action
o arquivo STRUTS.XML está em:
WEB-INF\classes\struts.xml
ARQUIVO WEB.XML
<?xml version=“1.0” encoding=“UTF-8”?>
<web-app version=“2.5” 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_2_5.xsd”>
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<servlet-mapping>
<servlet-name>struts</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
STRUTS.XML
<?xml version="1.0" encoding="UTF-8"?>
<!–
Document : struts.xml
Created on : 18 de Abril de 2008, 18:33
Author : dacior
Description:
Purpose of the document follows.
–>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
“http://struts.apache.org/dtds/struts-2.0.dtd”>
<struts>
<package name=“default” extends=“struts-default”>
<action name=“helloWorld” class=“struts2.actions.HelloWorldAction”>
<result name=“success”>/helloWorld.jsp</result>
</action>
</package>
package struts2.actions;
import com.opensymphony.xwork2.ActionSupport;
/**
-
@author Jair Rillo Junior
*/
public class HelloWorldAction extends ActionSupport {private String message;
/**
- This method will be performed when the action is called
/
public String execute() throws Exception {
message = “Hello World”;
return SUCCESS;
}
/* -
@return Returns the message.
/
public String getMessage() {
return message;
}
/* -
@param message The message to set.
*/
public void setMessage(String message) {
this.message = message;
}
}
- This method will be performed when the action is called
<%–
Document : index
Created on : 21/04/2008, 21:20:15
Author : dacior
–%>
<%@page contentType=“text/html” pageEncoding=“UTF-8”%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<HTML>
<TITLE>index.jsp</TITLE>
<HEAD></HEAD>
<BODY>
Click here to test the Struts Action
</BODY>
</HTML>
<%@page contentType=“text/html”%>
<%@page pageEncoding=“UTF-8”%>
<%–
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library… action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
–%>
<%–
<%@taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c”%>
–%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<%@taglib uri="/struts-tags" prefix=“s” %>
<HTML>
<HEAD>
<TITLE>helloWorld.jsp</TITLE>
</HEAD>
<BODY>
<s:property value=“message”/>
</BODY>
</HTML>
Gostaria de saber o que ta errado!!!