问题描述
我想在打开 BeforeLogin 页面时使用 JavaScript 函数将我的 JSP 重定向到另一个页面.但我收到以下错误消息.
I want to redirect my JSP to another page by using JavaScript function when I open the BeforeLogin page. But I got below error message.
找不到 Struts 调度程序.这通常是由于使用没有关联过滤器的 Struts 标签造成的.Struts 标签仅在请求通过其 servlet 过滤器时可用,该过滤器会初始化此标签所需的 Struts 调度程序.
The Struts dispatcher cannot be found. This is usually caused by using Struts tag without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.
我不知道该怎么办.
BeforeLogin.jsp:
function newpage(){
window.open("Login.jsp");
}
<body onLoad="goNewWin()">
<a href="BeforeLogin.jsp">click here to login</a>
</body>
Login.jsp:
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>
<s:text name="Login"/>
</title>
</head>
<body> ..... </body>
web.xml:
<filter>
<filter-name>DispatcherFilter</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>DispatcherFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
struts.xml:
<package name="struts2" namespace="/" extends="struts-default">
<action name="login" class="com.action.LogonAction">
<result name="input">Login.jsp</result>
</action>
推荐答案
创建无操作结果并使用它来代替 JSP.
Create actionless result and use it instead of JSP.
struts.xml:
<action name="showLogin">
<result>Login.jsp</result>
</action>
JS:
function newpage(){
window.open("showLogin");
}
说明:
错误清楚地表明
这通常是由于使用没有关联过滤器的 Struts 标签引起的
This is usually caused by using Struts tags without the associated filter
这意味着你里面有一个JSP和Struts标签,但是这个JSP没有被过滤器使用,因为它可能是一个欢迎文件,即index.jsp,错误代码文件,即404.jsp,配置在web.xml中.
it means that you have a JSP and Struts tags inside it, but this JSP is not used by the filter, because it could be a welcome file, i.e. index.jsp, error code file, i.e. 404.jsp, configured in the web.xml.
在涉及映射到资源的任何过滤器或 servlet 之前,这些资源由 Web 服务器处理.
These resources are handled by the web server before any filter or servlet mapped to the resource is being involved.
通常欢迎文件包含指向有效操作的重定向代码,然后将其分派到可以具有 Struts 标记的 JSP.不要在您的应用程序中直接使用 JSP,而是使用操作.
Usually welcome files contain a redirect code to a valid action which then dispatch to a JSP that can have Struts tags. Don't use JSPs directly in your application, use actions instead.
这篇关于如何使用JavaScript函数重定向到Struts2中的另一个jsp页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)