Monday, 15 August 2011

struts2 - Text never being set in controller when redirect occurs with struts -



struts2 - Text never being set in controller when redirect occurs with struts -

i have been trying larn angularjs/mvc/struts lately , can't seem 1 lastly thing working on application.

i have struts folder within actions.xml struts related actions.

inside have helloaction class gets basic greeting string, homecoming success , goes action.xml display view - hello.jsp.

this link utilize hello.jsp on localhost: http://localhost:8080/application/hello.jsp

here code...

actions.xml

<action name="hello" class="com.testapplication.actions.helloaction" > <result name="success">/hello.jsp</result> </action>

helloaction.java

package com.testapplication.actions; import com.opensymphony.xwork2.action; public class helloaction implements action { private string greeting; @override public string execute() throws exception { setgreeting("hello struts 2"); homecoming "success"; } public string getgreeting() { homecoming greeting; } public void setgreeting(string greeting) { this.greeting = greeting; } }

hello.jsp

<%@ taglib prefix="s" uri="/struts-tags" %> <!doctype html> <html> <head> <title>hello</title> </head> <body> <h1><s:property value="greeting" />!!!</h1> </body> </html>

my greeting never beingness displayed though. able render page no "hello struts 2"

model-view-controller struts2

No comments:

Post a Comment