java - How to pass a value to an action in Struts 2 when you don't have a form? -
i've written submit button this:
<s:submit type="button" value="delete" action="%{notesdeleteurl}" theme="simple"/>
and i've defined url this.
<s:url value="notesdeleteaction.action" id="notesdeleteurl" > <s:param name="noteid"><s:propertyvalue="inote" /> </s:param> </s:url>
so basically, have no < s:form > tag on jsp need call action submit button while passing value it. , error.
- there no action mapped namespace [/] , action name [notesdeleteaction?noteid=48] associated context path [/abc].
so understand it's unable resolve action because of added parameter, how else can send value action?
your error nothing parameter. struts doesn't know url /notesdeleteaction
you'll need include action in struts.xml file:
<package name="yourpackage" namespace="/" extends="struts-default"> <action name="notesdeleteaction" class="foo.yourclass"> <result>somepage.jsp</result> </action> </package>
there 2 ways parameter in class, foo.yourclass
one way is:
map parameters = actioncontext.getcontext().getparameters();
the other way class implement org.apache.struts2.interceptor.parameteraware
Comments
Post a Comment