Results 1 to 2 of 2
  1. #1
    flyare is offline Member
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Unhappy Help me about Struts 2!

    Hi there!
    Thanks about you read!

    I am newbie Struts 2 developer. I am trying make a sample with Struts
    My problem:
    - I send request (GET method) http://localhost:8080/comment.action?id=1 to server.
    - Action CommentAction receive with method execute() and return SUCCESS
    Java Code:
    public class CommentAction extends ActionSupport implements ModelDriven<Message> {
        private Message message = new Message();
        private int id;
    
        private MessageService service = new MessageServiceImp();
    
        public String execute() {
            try {
                this.message = service.getMessageById(id);
                return SUCCESS;
            } catch (Exception e) {
                return ERROR;
            }
        }
    
        public Message getModel() {
            return message; 
        }
    
        public int getId() {
            return id;
        }
    
        public void setId(int id) {
            this.id = id;
        }
    }
    - I see message object is not null with "id=1" and int id = 1 in this action.
    - My UI follow code
    Java Code:
    <p>My message ID:</><s:property value="id"/><br/>
    <p>My message author:</><s:property value="author"/><br/>
    I want show message.id. But it show "0" and message.author is " "
    I don't know why?
    Please help me! Understand this problem!
    Thanks!

  2. #2
    flyare is offline Member
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Default Re: Help me about Struts 2!

    I resolve this problem. Because, in message object has id property, the same with id property in Action. This maybe reason.
    Thanks for your view!

Similar Threads

  1. Struts: How to display a grid in Struts??
    By fabbero in forum New To Java
    Replies: 1
    Last Post: 07-13-2011, 05:18 PM
  2. struts-config.xml in struts.
    By arjun_duddu in forum Advanced Java
    Replies: 0
    Last Post: 09-01-2010, 01:54 PM
  3. decorator.jsp problem building Struts Menu in JSP when Struts action is used
    By dkirvan in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-29-2010, 05:33 AM
  4. Struts 1 vs Struts 2
    By priyanka.dandekar in forum Web Frameworks
    Replies: 1
    Last Post: 10-06-2008, 09:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •