struts2 displays the error message in addActionError on the jsp page

Write this in the action:

public void validate() {
		if(!"admin".equals(name)||!"admin".equals(password)){
			addActionError("Username or password is incorrect");
		}
	}

in jsp

<%@ taglib uri="/struts-tags" prefix="s" %>
...
<body>
   <s:actionerror/>
</body>
Remember to write this sentence in struts.xml: <result name="input">/login.jsp</result>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325394844&siteId=291194637