Struts 2 executar uma action - .do

4 respostas
N

Olá
no struts 1 eu mapeo a action dessa maneira:

<action path="helloworld "name="HelloWorld" type="example.HelloWorld">
        <result>/example/HelloWorld.jsp</result>
        <result>/example/listaCliente.jsp</result>            
   </action>

e executo a action dessa maneira:

http:\locathost:8080\teste\helloworld.do

Agora como faço para executar essa acttion do struts 2? falta alguma coisa no mapeamento?

<action name="HelloWorld" class="example.HelloWorld">
        <result>/example/HelloWorld.jsp</result>
        <result>/example/listaCliente.jsp</result>            
    </action>

Grato

4 Respostas

aleck

Utilize o .action no lugar do .do .

N

Olá
Aleck
Executei conforme vc me instruiu mais não deu certo nao

http://localhost:8080/struts2/HelloWorld.action

Erro:

type Status report

message There is no Action mapped for namespace / and action name HelloWorld.

description The requested resource (There is no Action mapped for namespace / and action name HelloWorld.) is not available.

Parece que tem algo errado no mapeamento.

Tem ideia do que possa ser?

Grato

aleck

No web.xml

&lt;filter&gt;
	 	&lt;filter-name&gt;struts-cleanup&lt;/filter-name&gt;
	 	&lt;filter-class&gt;org.apache.struts2.dispatcher.ActionContextCleanUp&lt;/filter-class&gt;
	&lt;/filter&gt;

	&lt;filter&gt;
		&lt;filter-name&gt;struts&lt;/filter-name&gt;
		&lt;filter-class&gt;org.apache.struts2.dispatcher.FilterDispatcher&lt;/filter-class&gt;
	&lt;/filter&gt;

	&lt;filter-mapping&gt;
	 	&lt;filter-name&gt;struts-cleanup&lt;/filter-name&gt;
	 	&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
	&lt;/filter-mapping&gt;

	&lt;filter-mapping&gt;
		&lt;filter-name&gt;struts&lt;/filter-name&gt;
		&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
	&lt;/filter-mapping&gt;

No struts.xml

&lt;action name="consultarPedido" class="br.com.teste.action.ConsultarPedidoAction" method="execute"&gt;
&lt;result name="fwd-entrada-consulta"&gt;/WEB-INF/jsp/entrada-consulta.jsp&lt;/result&gt;
&lt;/action&gt;
I

Não sei criar uma classe action.

WEB_INF / classe / br / com/ x / x / x / action e form

quando abro não consigo modificar o arquivo.class
mudo a extensão e quando abro aparece codigo maluco.

Criado 8 de junho de 2009
Ultima resposta 10 de dez. de 2009
Respostas 4
Participantes 3