Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So maybe I don't understand the question. But I hope this example helps (btw this code will not work its just to help give you an idea of how it sturts2 works its magic); So for form input you need to have a holder class in java, so you can call your date from your action class such as Holder.java:</p> <pre><code>public class Holder{ pirvate Date date; public getDate(){ return date; } public setDate(Date date){ this.date = date; } } </code></pre> <p>Your Holder.java validation so you can make sure its a date Holder-validation.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"&gt; &lt;validators&gt; &lt;field name="date"&gt; &lt;field-validator type="date"&gt; &lt;message&gt;&lt;![CDATA[ Must be a date ]]&gt;&lt;/message&gt; &lt;/field-validator&gt; &lt;/field&gt; &lt;/validators&gt; </code></pre> <p>Your action class where you call your make sure holder.getdate to get your date getDateAction.java:</p> <pre><code>private Holder holder; public class getDateAction{ public String execute(){ //get your date Date date = holder.getDate(); return SUCCESS; } } </code></pre> <p>Your jsp form where you give the client the ability to input the date. Make sure for input name="holder.date". Here is site.jsp:</p> <pre><code>&lt;s:form id="Form" name="MyForm" action="getDateAction" method="post" class="form"&gt; &lt;input type="text" name="holder.date" id="date" size="25" value="" class="required text"&gt; &lt;/s:form&gt; </code></pre> <p>and last but not least your struts.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"&gt; &lt;struts&gt; &lt;package name="example" extends="struts-default"&gt; &lt;action name="getdate" class="com.location.action.getDateAction"&gt; &lt;result&gt;example.jsp&lt;/result&gt; &lt;/action&gt; &lt;/package&gt; &lt;/struts&gt; </code></pre> <hr> <p>There is an explanation of Struts2 date Format here at: <a href="http://www.roseindia.net/struts/struts2/date/struts-2-date-format.shtml" rel="nofollow noreferrer">Struts 2 Date Format Examples</a></p> <p>But I believe the tag you are looking for in jsp is </p> <pre><code>&lt;s:date name="Date_Name" format="yyyy-MM-dd" /&gt; </code></pre> <p>Where Date_Name is the Date object in Java.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload