Erro Struts2 - Iniciante

0 respostas
A

E ae galera, blz?

Estou criando um Hello World com struts2 mas to recebendo um erro que não consegui resolver.

Meu código é bem simples:

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" 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" id="WebApp_ID" version="3.0">
  <display-name>ProjetoStruts</display-name>

  <filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
  
</web-app>
Action
package com.fiap.action;

import com.opensymphony.xwork2.ActionSupport;
 
public class HelloWorldAction extends ActionSupport {

	private String message;
    
    public String execute()
    {
        setMessage("Essa é uma mensagem do Hello World do Struts 2!");
	    return SUCCESS;
    }
    
    public String getMessage() {
        return message;
    }
    
    public void setMessage(String message) {
        this.message = message;
    }
    
}
jsp
<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
	<jsp:directive.page contentType="text/html; charset=ISO-8859-1" 
		pageEncoding="ISO-8859-1" session="false"/>
	<jsp:output doctype-root-element="html"
		doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
		omit-xml-declaration="true" />
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
    <title>Struts 2 - Exemplo de Hello World</title>
</head>
<body>

<h2><s:property value="message"/></h2>
 
</body>
</html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Insert title here</title>
</head>
<body>

</body>
</html>
</jsp:root>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!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" namespace="/" extends="struts-default">
		<action name="hello" class="com.fiap.action.HelloWorldAction">
			<result name="sucess">/HelloWorld.jsp</result>
		</action>
	</package>
</struts>

tenho as seguintes libs adicionadas no projeto:

asm-3.1.jar
asm-commons-3.1.jar
commons-beanutils-1.8.0.jar
commons-chain-1.2.jar
commons-collections-3.1.jar
commons-digester-2.0.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
commons-lang3-3.1.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.jar
commons-validator-1.3.1.jar
freemarker-2.3.16.jar
javassist-3.11.0.GA.jar
ognl-3.0.1.jar
struts2-convention-plugin-2.2.3.1.jar
struts2-core-2.2.3.1.jar
xwork-core-2.2.3.1.jar

Eu tento acessar pela URL: http://localhost:8090/ProjetoStruts/HelloWorldAction/hello

E dá o seguinte erro:

There is no Action mapped for namespace [/HelloWorldAction] and action name [hello] associated with context path [/ProjetoStruts]

já tentei variar essa URL, por exemplo: http://localhost:8090/ProjetoStruts, http://localhost:8090/ProjetoStruts/hello

E sempre dá esse There is no action...

desde já agradeço a quem puder ajudar.

Criado 26 de maio de 2014
Respostas 0
Participantes 1