EDITADO: Havia esquecido de postar a imagem do projeto com a tela de erro na Action
Existe no site da caelum, um lugar para baixar o exemplo?
Galera,
Peguei a nova apostila fj-21 da caelum, na verdade estava usando a versão anterior, e descobri que no site tinha a nova versão.
Estou no capítulo “Struts 2”.
Comentário: que apostila ótima tanto fj-11 (li) e fj-21.
Mas então galera, é o seguinte, criei o pacote action dentro do projeto chamado “fj21-tarefas” o seguinte arquivo dentro dele:
OlaMundoAction.java
[code]package action;
import javax.xml.ws.Action;
public class OlaMundoAction {
@Action(value = “olaMundoStruts”, results = {
@Result(location = “/olaMundoStruts.jsp”, name = “ok”) }
)
public String execute() {
System.out.println(“Executando a lógica com Struts2”);
return “ok”;
}
}
[/code]
meu arquivo web.xml esta assim:
<?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_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>fj21-tarefas</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>
<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>
</web-app>
e criei um arquivo dentro da WebContent chamado “olaMundoStruts.jsp” só com html básico.
quanto tiro as tags de filter do struts que estão no web.xml meu index.js (criei para testar o diretorio) funciona, quando retiro ele não funciona mais.
O eclipse aponta erros conforme figura em .
outra dúvida, para o eclipse reconhecer as bibliotecas do strutus eu preciso só colocar os .jar dentro da pasta “WebContent\WEB-INF\lib” ? ou melhor importar pelo assistente do eclipse?