First, you must add the statement in the class corresponding to the ACTION, for example:
Do you want to write this. addFieldErrZ into T. java? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> vcig =" name "," name is error ");, add a name attribute with the content name is error.
package com.xjtu.st;import com.opensymphony.xwork2.ActionSupport;import com.xjtu.dto.DTOStudent;import com.xjtu.vo.Student;public class T extends ActionSupport {String name;public String exe() {System.out.println(name);if (name == null || !name.equals("yangzhi")) {this.addFieldError("name", "name is error");return "error";}return "aaa";}public String getName() {return name;}public void setName(String name) {this.name = name;}}
Configure the struts tag on the page to jump.
<%@ taglib uri="/struts-tags" prefix="s" %>
Write in the BODY of HTML
// Check
// The system automatically enters the information you saved
// This tag is the value in ValueStack, which has many attributes. errors is one of them.
//
Errors is a map, which extracts all key-value pairs
//
Errors. name is a string array. This sentence is all the content in the output, because it can contain a lot of information in name.
//
Retrieve the nth Value
S Delete student