Java 有时会意外地发生页面未找到错误。 console.log(“会话完成”); var url=window.location.href; var prc=“${pageContext.request.contextPath}”; 如果(url.indexOf(prc+“/雇主”)!=-1) window.location=“${pageContext.request.contextPath}/registereduserlogin”; 否则如果(url.indexOf(prc+“/用户”)!=-1 | url.indexOf(prc+”/appmanage”)!=-1 | url.indexOf(prc+“/提供商”)!=-1 | url.indexOf(prc+”/报价)!=-1 | url.indexOf(prc+“/计划”)!=-1){ window.location=“${pageContext.request.contextPath}/bpauserlogin”; } 否则{ window.location=“${pageContext.request.contextPath}/home”; } 双酚A 找不到页面 返回上一页

Java 有时会意外地发生页面未找到错误。 console.log(“会话完成”); var url=window.location.href; var prc=“${pageContext.request.contextPath}”; 如果(url.indexOf(prc+“/雇主”)!=-1) window.location=“${pageContext.request.contextPath}/registereduserlogin”; 否则如果(url.indexOf(prc+“/用户”)!=-1 | url.indexOf(prc+”/appmanage”)!=-1 | url.indexOf(prc+“/提供商”)!=-1 | url.indexOf(prc+”/报价)!=-1 | url.indexOf(prc+“/计划”)!=-1){ window.location=“${pageContext.request.contextPath}/bpauserlogin”; } 否则{ window.location=“${pageContext.request.contextPath}/home”; } 双酚A 找不到页面 返回上一页,java,javascript,jsp,html,Java,Javascript,Jsp,Html,这是我的jsp页面 此代码工作正常,但有时会意外或无意地发生“找不到页面”错误 这个代码有什么错误 我把JavaScript和脚本放在一起使用。这就是原因吗 请建议更好的解决方案。当加载jsp页面或从此jsp导航到其他页面时,实际发生错误。当导航到其他页面时,请添加更多详细信息,如页面中的链接。请编辑并添加您拥有的任何详细信息,以便我们能够帮助您!!通常出现在这个url.indexOf(prc+“/provider”)=-1.url.indexOf(prc+“/提供者”)=-1只是一个无法给出的

这是我的jsp页面

此代码工作正常,但有时会意外或无意地发生“找不到页面”错误

这个代码有什么错误

我把JavaScript和脚本放在一起使用。这就是原因吗


请建议更好的解决方案。

当加载jsp页面或从此jsp导航到其他页面时,实际发生错误。当导航到其他页面时,请添加更多详细信息,如页面中的链接。请编辑并添加您拥有的任何详细信息,以便我们能够帮助您!!通常出现在这个url.indexOf(prc+“/provider”)=-1.url.indexOf(prc+“/提供者”)=-1只是一个无法给出的检查页未找到。。您的意思是window.location=“${pageContext.request.contextPath}/bpauserlogin”;
 <%@page import="org.apache.shiro.SecurityUtils"%>
    <%@page import="org.apache.shiro.subject.Subject"%>
    <%@ page language="java" isErrorPage="true"
        contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <script>
    <%
        Subject currentUser = SecurityUtils.getSubject();   
        System.out.println("Session:"+currentUser.getPrincipal());
        if(currentUser.getPrincipal()==null && (session.getAttribute("username") == null)){
    %>
        console.log("session finished");
        var url = window.location.href; 
        var prc = "${pageContext.request.contextPath}";
        if(url.indexOf( prc +"/employer")!=-1)
            window.location = "${pageContext.request.contextPath}/registereduserlogin";
        else if(url.indexOf(prc + "/user")!=-1 || url.indexOf(prc +"/appmanage")!=-1 || url.indexOf(prc +"/provider")!=-1 || url.indexOf(prc +"/quote")!=-1 || url.indexOf(prc +"/plan")!=-1){
            window.location = "${pageContext.request.contextPath}/bpauserlogin";
        }
        else{
            window.location = "${pageContext.request.contextPath}/home";
        }
    <%
    }
    %>
    </script>
    <link href="${pageContext.request.contextPath}/css/main.css"
        rel="stylesheet" type="text/css">
    <title>bpa</title>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon">
    <link rel="icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <div style="text-align: center; margin: 100px;">

            <div class="center_btn">
                <h1>Page Not Found</h1>
                <br />
                <br />
                <button onclick="history.back()" class="btn">Back to Previous Page</button>
            </div>
        </div>
    </body>
    </html>