Stephan sounds as if the navigation may not be working
 instead of annotations what happens if you use the *normal* struts.xml package 
and action declarations e.g
<interceptors>           <interceptor-stack name="guest" >
                       <interceptor-ref name="params">
                                              <param 
name="excludeParams">dojo\..*,^struts\..*,_.*</param>                           
       </interceptor-ref>           
           </interceptor-stack>            </interceptors>

<struts>......
    <package name="NamespaceName" namespace="/" extends="struts-default">       
 <action name="myAction">
            <result name="success">/success.jsp</result>            <result 
name="error">/error.jsp</result>
           <interceptor ref-name="guest"/>        </action>    </package>
.....</struts>
Martin

 > CC: user@struts.apache.org
> From: nikhilesh.sov...@gmail.com
> Subject: Re: json data are not passed in Stuts action
> Date: Thu, 22 Nov 2012 06:20:38 +0530
> To: user@struts.apache.org
> 
> Stephan,
> 
> Are you sure your data is getting passed in request body as you are making an 
> Ajax call ?
> 
> On 21-Nov-2012, at 9:16 PM, Stephan Schreck <stephan.schr...@eurodyn.com> 
> wrote:
> 
> > Hello,
> > i have a problem with my struts 2 application. I try to send some json data 
> > in my action from the following
> > script.
> > 
> > <script>
> >                $(document).ready(function () {
> > 
> >               var data = {data: {jsonKey1 : "one", jsonKey2: "two", 
> > jsonKey3: [1, 2, 3, 4, 5], jsonKey4: {a: "A", b: 2, c: "3"}, jsonKey5: 2, 
> > jsonKey6: "2"}};
> >                    jQuery.ajax(
> >                    {
> >                        type: "POST",
> >                        url: "http://localhost:8080/myAction";,
> >                        data: jQuery.toJSON(data),
> >                        dataType: "json",
> >                        async: false ,
> >                        contentType: "application/json; charset=utf-8",
> >                        success: function(){window.alert("Done");}
> >                    });
> >                });
> >            </script>
> > 
> > 
> > 
> > The action is called without any problem. What i am trying to achieve is to 
> > send the data to my action and set the Map data. This is something
> > that does not work.  In my struts.xml i have included the JSONInterceptor 
> > in my stack, as seen below:
> > 
> > ...
> > ...
> >                <interceptor-ref name="scopedModelDriven" />
> >                <interceptor-ref name="modelDriven" />
> >                <interceptor-ref name="fileUpload" />
> >                <interceptor-ref name="json" />
> >                <interceptor-ref name="staticParams" />
> >                <interceptor-ref name="actionMappingParams" />
> > 
> >                <interceptor-ref name="params">
> >                    <param 
> > name="excludeParams">dojo\..*,^struts\..*,_.*</param>
> >                </interceptor-ref>
> > ...
> > ...
> > 
> > 
> > 
> > Here the action that is called while the script is running.
> > 
> > @Injectable
> > @Result(name = "success", type = "json")
> > @ParentPackage("json-default")
> > public class MyAction extends BaseAction {
> > 
> > 
> >    Map data = new HashMap();
> > 
> >    public String execute() throws Exception {
> > 
> >        return SUCCESS;
> >    }
> > 
> > 
> >    public Map getData() {
> >        return data;
> >    }
> > 
> >    public void setData(Map data) {
> >        this.data = data;
> >    }
> > }
> > 
> > 
> > 
> > I have added some brakepoints in  the JSONInterceptor. In there there is a 
> > variable String contentType = request.getHeader("content-type");
> > The variable contentType seems to be always null. So maybe that is where 
> > the problem starts from. The data sent are not
> > recognized as json data maybe.
> > 
> > All in all and in a few lines, i am trying to send the data from the script 
> > to my struts Action but it seems that i am missing something
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
                                          

Reply via email to