views:

1087

answers:

1

I have a question, but I couldn't find a solution for my problem in Korean web community.

<s:form name="form1" method="post" action="products" theme="simple">
  <s:hidden name="code" value="%{code}"/>
  <s:submit type="button" name="method:selectSale" value="goPage"/>
</s:form>

This code has no problem.

But, I want to use "anchor" instead of "submit" tag. I just want to use hyperlink and 'post' way, not 'get'. How can I do this? Help me please~ :)

<s:form name="form1" method="post" action="products" theme="simple">
  <s:hidden name="code" value="%{code}"/>
  <a href="#" onclick="javascript:document.form1.submit()">goPage</a>
</s:form>

It doesn't work. :(

The main problem is how to get "method:selectSale".

in struts.xml,

<action name="products" class="sample.ProductsAction">
  <result>abc.jsp</result>
  <result name="selectSale">selectSale.jsp</result>
</action>

and then, in ProductsAction.java,

public String selectSale() throws Exception {
  // ~~~
  return "selectSale"
}

Ok, now, I have a question.

where do i have to put "selectSale" on code? ( using <s:a> or <a:> )

+1  A: 

Define a and use it in your anchor.

<s:url id='IdAnchor' action='products' method='selectSale'/>

<a href="${IdAnchor}">goPage</a>

Regards,

pedromarce