file set:

Launch JSP page: TestActionParam.jsp
Action: ActionParam.java
Response JSP page: ActionParam.jsp
Struts config file: struts.xml

source code:

******** TestActionParame.jsp ******

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
  <head>
    <meta http-equiv="Content-Type"
content="text/html; charset=windows-1252"/>
    <title>TestActionParam</title>
  </head>
  <body>
    <br>
    <center><a
href='actionparam.action?par=YES'>test</a></center>  
  </body>
</html>

******** ActionParam.java ********

package test;

import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;
import org.apache.struts2.interceptor.ParameterAware;

public class ActionParam extends ActionSupport
implements ParameterAware {
    public static final String MESSAGE = "Test passed:
";
    private String message;
    private Map parameters;
    public String execute() throws Exception {
        String[] par =
(String[])parameters.get("par");
        String parVal=((par!=null)?par[0]:"NO");
        setMessage(MESSAGE + " " + parVal);        
        return "success";
    }
    public void setMessage(String message){
        this.message = message;
    }
    public String getMessage(){
        return message;
    }    
    public void setParameters(Map parameters) {
     this.parameters=parameters;
    }
    public Map getParameters() {
     return parameters;
    }
}

********** ActionParam.jsp ***********

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
  <head>
    <meta http-equiv="Content-Type"
content="text/html; charset=windows-1252"/>
    <title>ActionParam</title>
  </head>
  <body>
  <h2><s:property value="message"/></h2>
 </body>
</html>

*********** struts.xml ***********

<!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"></package>
    <package name="test" extends="struts-default">
        <action name="actionparam"
class="test.ActionParam">
            <result>/ActionParam.jsp</result>
            <interceptor-ref name="servlet-config" />
            <interceptor-ref name="params"/>
        </action>
    </package>
</struts>

**********************

Result: passed "par" parameter always null ... (though
it is actually present in the URL)

******** WHERE'S THE DAMN PROBLEM?!? ********

A very discouraged Struts 2 newbie...

Thanks in advance.

              Ric



      ___________________________________ 
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: 
http://it.docs.yahoo.com/nowyoucan.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to