Javatpoint Logo
Javatpoint Logo

Struts2 DateTimePicker Example

1) Create index.jsp for input

This jsp page creates a form using struts UI tags. It receives name, password and email id from the user.

<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<sx:head  />
<s:form action="DateTimePicker" method="POST">
<sx:datetimepicker name="todayDate" label="Format (yyyy-mm-dd)" displayFormat="yyyy-MM-dd"/>
<sx:datetimepicker name="todayDate2" label="Format (dd-mm-yyyy)" displayFormat="dd-MMM-yyyy"/>

2) Create the action class

This action class inherits the ActionSupport class and overrides the execute method.

3) Create struts.xml

This xml file defines an extra result by the name input, and an interceptor jsonValidatorWorkflowStack.

 <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" 
<package name="s" extends="struts-default">
<action name="DateTimePicker" class="mypack.DateBean">

4) Create view component

It is the simple jsp file displaying the information of the user.

<%@ taglib prefix="s" uri="/struts-tags" %>
first date:<s:property value="todayDate" />
second date:<s:property value="todayDate2" />

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA