开发者

how to pass a value from action to jsp in google app engine?

开发者 https://www.devze.com 2023-03-12 11:36 出处:网络
I want to pass en value from my action to the result jsp file in google app engine. google app engine 1.4.3 for java and strut2 2.1.8.1

I want to pass en value from my action to the result jsp file in google app engine. google app engine 1.4.3 for java and strut2 2.1.8.1

with the instruction of http://programmingpanda.blogspot.com/2009/07/struts-2-ongl-issue-on-google-app.html I already fixed the ongl listener.

in my action:

public String execute()
{
    ActionContext.getContext().getValueStack().set("user", "LovelyCat");
    return "success";
}

and 开发者_StackOverflowthe result page is this jsp page, and i try to get "user" in it:

    <%
    String name = (String)ActionContext.getContext().getValueStack().findValue( "user" );  
    out.write(name);
    %>

but name is null and it prints nothing. guys, please help me.


Use this

public String execute() {
    ActionContext.getContext().put("user", "LovelyCat");
    return SUCCESS;
}

.jsp

<s:property value="user" />

or more optimal

${user}


Do it the struts way. Just set the value in an action class property and then access it in JSP using the struts tags like <s:property>

In Action class:

public String execute()
{
   this.setUser("LovelyCat");
   return "success";
}

In JSP:

<s:property value="user"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消