有时会发生意外页面未找到错误。

时间:2013-12-13 11:13:48

标签: java javascript jsp html

 <%@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>

这是我的jsp页面。

此代码工作正常但有时会意外且无意中发现页面错误。

此代码有什么错误?

我一直使用JavaScript和脚本 - 这就是原因吗?

请建议更好的解决方案。

0 个答案:

没有答案