ChainedException no STRUTS

2 respostas
R

Srs.
No Struts, estou tentando implementar ChainedException baseado na idéia passada no livro Struts In Action(cap. 8), estou criando os erros na classe Action , e no JSP estou colocando uma referência ao erro, porém, apesar de saber que ocorre o erro, este não parece no JSP. O que devo fazer para mostrar o erro no JSP gerado na classe Action. Vou colocar o código do Action e o JSP, se precisar depois coloco o ActionForm.

trecho do JSP que mostraria o erro

<%@ taglib uri="/WEB-INF/tags/struts-html.tld" prefix="html" %> 
<%@ taglib uri="/WEB-INF/tags/fmt.tld" prefix="fmt" %>

<html:html locale="true">
<fmt:setBundle basename="java.MessageResources" scope="page" />

<head>                   
<title>Efetue Login</title>
  <html:base/> 
</head>
<body bgcolor="cyan">

<html:errors property="errologin" />  <%--este é a mensag de erro --%>

<html:form action="/Logar" focus="usuario"> 

.
.

trecho do Action que gera o erro

catch (Exception exception){
			ActionErrors errors = new ActionErrors();
			servlet.log("***   ACTION EXCEPTION :  ", exception);
			exception.printStackTrace();
			
			errors.add("errologin", new ActionMessage("erro.Login"));
			
			StringBuffer sb = new StringBuffer();
			sb.append(exception.getMessage());
			errors.add("errologintecnic", new ActionMessage("errotecnic",sb.toString()));
			
		}

Alguém saberia me dizer o que poderia estar faltando para a tag <html:errors property=“errologin” /> mostrar meu errologin, no caso erro.Login já está no meu arquivo de resources.

Desde já agradeço.

2 Respostas

R

STRUTS

resumindo, gostaria de saber como fazer para que um erro gerado no Action pela classe ActionErrors, apareça no JSP de resposta da requisição.

Grato,
Ruthênio

T
Tenta assim
&lt;%@ taglib uri=&quot;/WEB-INF/tags/struts-html.tld&quot; prefix=&quot;html&quot; %&gt; 
&lt;%@ taglib uri=&quot;/WEB-INF/tags/fmt.tld&quot; prefix=&quot;fmt&quot; %&gt; 

&lt;html&#58;html locale=&quot;true&quot;&gt; 
&lt;fmt&#58;setBundle basename=&quot;java.MessageResources&quot; scope=&quot;page&quot; /&gt; 

&lt;head&gt;                    
&lt;title&gt;Efetue Login&lt;/title&gt; 
  &lt;html&#58;base/&gt; 
&lt;/head&gt; 
&lt;body bgcolor=&quot;cyan&quot;&gt; 

&lt;html&#58;errors property=&quot;errologintecnic&quot; /&gt;  &lt;%--este é a mensag de erro --%&gt; 

&lt;html&#58;form action=&quot;/Logar&quot; focus=&quot;usuario&quot;&gt;
Criado 1 de junho de 2005
Ultima resposta 27 de jul. de 2005
Respostas 2
Participantes 2