Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: STRUTS2 with JSON

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow STRUTS2 with JSON

    I am unable to run the struts2 application with json. i want to display json in client side page.i m building json object in action class.any advice is accetable.
    <s:div id="my_result" >
    <s:property value="jsonData" /></s:div><s:form action="giveMeJsonData" theme="simple"><sj:submit targets="my_result" value="Example" /></s:form>
    <------ end of jsp client page--->
    <package name="TestJson" extends="json-default"><action name="giveMeJsonData" class="test.testAction" method="myFunction">
    <result type="json"><param name="root">jsonData</param></result> </action> </package>
    <----------------end of struts.xml------------------>
    public LinkedHashMap<String, String> getJsonData() { return jsonData; }
    public void setJsonData(LinkedHashMap<String, String> jsonData) { this.jsonData = jsonData; }
    public String execute() throws Exception {
    return SUCCESS;
    }

    public String myFunction() {
    jsonData = new LinkedHashMap<String, String>();
    jsonData.put("My name is", "marco");
    return SUCCESS;
    }


  2. #2
    Member
    Join Date
    Apr 2012
    Location
    Superior, CO, USA
    Posts
    80
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default Re: STRUTS2 with JSON

    Where do you actually convert anything to JSON? You've just got a Map of Strings. This isn't PHP - you've got to do something to convert to JSON.
    Need Java help? Check out the HotJoe Java Help forums!

Similar Threads

  1. JSON reader
    By Rootntootn in forum Java Theory & Questions
    Replies: 4
    Last Post: April 9th, 2012, 09:14 AM
  2. PHP Developer - OOP / MVC / XML / JSON - 40,000 (NEG)
    By JacquelineRobbins in forum Paid Java Projects
    Replies: 0
    Last Post: January 12th, 2012, 05:58 AM
  3. struts2 is better or spring?
    By the light in forum Web Frameworks
    Replies: 0
    Last Post: June 26th, 2011, 11:10 AM
  4. Parsing JSON Feed
    By sogorman in forum Other Programming Languages
    Replies: 2
    Last Post: June 6th, 2011, 03:02 AM
  5. MultiLevel Combobox in Struts2
    By tcstcs in forum Web Frameworks
    Replies: 0
    Last Post: May 23rd, 2011, 06:47 AM

Tags for this Thread