[英]Execute and Wait Interceptor in struts2
I'm getting an error ie 我遇到错误,即
WARNING: Could not find token mapped to token name token 警告:找不到映射到令牌名称令牌的令牌
I didn't understand please tell me why I'm getting this error and how to resolve it. 我不明白,请告诉我为什么会收到此错误以及如何解决。
struts.xml struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="interceptorExecAndWait" extends="struts-default">
<action name="execAndWaitInterceptor" class="com.interceptor.execandwait.action.ExecuteAndWait">
<!-- <interceptor-ref name="defaultStack"/> -->
<interceptor-ref name="completeStack"/>
<interceptor-ref name="execAndWait">
<param name="delay">1000</param>
</interceptor-ref>
<!-- <interceptor-ref name="execAndWait"/> -->
<result name="success">/welcome.jsp</result>
<result name = "wait">/wait.jsp </result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
ExecuteAndWait.java ExecuteAndWait.java
public class ExecuteAndWait {
String userName;
String password;
public String execute() throws InterruptedException {
if (userName.equals("Admin") && password.equals("user")) {
System.out.println("ok");
Thread.sleep(5000);
return "success";
} else {
return "error";
}
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
Let me know where I make mistakes 让我知道我在哪里犯错
Thanks :) 谢谢 :)
You don't show your refresh
meta tag, but it's likely it doesn't include the includeParams="all"
in the <s:url>
tag, eg, 您没有显示您的refresh
元标记,但是很可能它没有在<s:url>
标记中包含includeParams="all"
,例如,
<head>
<title>Please wait</title>
<meta http-equiv="refresh" content="5;url=<s:url includeParams="all" />"/>
</head>
Add 加
<interceptor-ref name="completeStack"/>
<interceptor-ref name="execAndWait">
<param name="delay">1000</param>
<param name="delaySleepInterval">500</param>
</interceptor-ref>
in your struts.xml ie, 在您的struts.xml中,即
<package name="interceptorExecAndWait" extends="struts-default">
<action name="execAndWaitInterceptor" class="com.interceptor.execandwait.action.ExecuteAndWait">
<interceptor-ref name="completeStack"/>
<interceptor-ref name="execAndWait">
<param name="delay">1000</param>
<param name="delaySleepInterval">500</param>
</interceptor-ref>
<result name="success">/welcome.jsp</result>
<result name = "wait">/wait.jsp </result>
<result name="error">/error.jsp</result>
</action>
</package>
Include the includeParams="all" and http-equiv="Refresh" in the meta tag, in your wait.jsp ie, 在您的wait.jsp中的meta标签中包含includeParams =“ all”和http-equiv =“ Refresh” ,即
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Refresh" content="5;url=<s:url includeParams="all" />">
<title>Waiting</title>
</head>
<body>
<div align="center">
<h2>Please wait while we verify your credentials.. </h2>
</div>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.