test

@Validation public class PostItemAction extends BaseAction { //here BaseAction extends ActionSupport implements ModelDriven, ServletResponseAware, ServletRequestAware @Validations( requiredStrings={ @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "item.itemName", message = "", key = "errorItemNameRequired"), @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "item.itemdescription", message = "", key= "errorItemDescriptionRequired"), @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "amount", message = "", key= "errorStartPriceRequired") } ) public String sellItem() throws IOException{ return SUCCESS; } } ------------------ Here item.itemName--> item is object of ItemVO.java (simple pojo or talking to db..) itemName is field of ItemVo --------------------- key -->errorItemNameRequired-->you have in Resource file --------- JSP contains .. something like <s:form action="PostItemAction_sellItem"> <s:textfield name="item.itemName" /> <s:textfield name="item.itemdescription" /> <s:datetimepicker name="item.startDate" /> </s:form> --------- strust.xml-->entry <action name="PostItemAction_*" method="{1}" class="com.action.PostItemAction"> <result>/item/yourother.jsp</result> </action>

你可能感兴趣的:(java,xml,jsp)