我正在研究struts 2项目,面对一个奇怪的问题,非常需要你在这个问题上的帮助
1 - 我开发了一个带有bootstrap css的网页,实际上是本地的 我的意思是css和js文件在我的本地
2 - 我为那个jsp开发了一个struts动作,当你按下一个按钮时,它会调用一个动作类并做一些业务逻辑并返回到同一个页面
我的问题是当该页面加载第一次css已正确应用但按钮点击流程后将转到struts2配置并映射到动作返回成功从该动作我返回到相同的jsp,除了这次在同一个jsp css没有正确加载
我现在提到的那个动作是在一个struts-school.xml中,它被包含在struts.xml中 - 我不相信这会是问题但是以防万一
注意:它是一个maven项目,当我开始但后来转换为maven时实际上是一个Web项目
在struts 2动作之前和struts 2动作之后渲染时,请浏览相同jsp的代码和图像
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="width = device-width, initial-scale = 1">
<link href="CustomCssAndScript/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="CustomCssAndScript/bootstrap/js/jquery.min.js"></script>
<script src="CustomCssAndScript/bootstrap/js/bootstrap.min.js"></script>
<title>Insert title here</title>
</head>
<body>
<div class="container-fluid">
<%@include file="schoolHeaderMenus/schoolHeader.jsp" %>
<%@include file="schoolLeftSideMenus/sideMenu1.jsp" %>
</div>
</body>
</html>
<%@ 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 name="viewport" content="width = device-width, initial-scale = 1">
<link href="CustomCssAndScript/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="CustomCssAndScript/bootstrap/js/jquery.min.js"></script>
<script src="CustomCssAndScript/bootstrap/js/bootstrap.min.js"></script>
<title>Insert title here</title>
<style type="text/css">
.jumbotron {
background: #000 url("images/FotorCreated.jpg");
height:50px;
background-repeat: no-repeat;
background-size: cover;
border-bottom:1px solid #ff6a00
}
</style>
<style>
.nav > li > a:hover, .nav > li > a:focus {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="jumbotron">
<div class="row">
<div class="pull-right">
<ul class="nav navbar-nav">
<li class="active"><a href="#" style="color: white;"><span class="glyphicon glyphicon-home"></span> Home</a></li>
<li><a href="#" style="color: white;">Students Managment</a></li>
<li><a href="#" style="color: white;">Staff Managment</a></li>
<li><a href="#" style="color: white;">Library Managment</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#" style="color: white;"> Add Members<span class="caret"></a>
<ul class="dropdown-menu">
<li><a href="school/addTeachersAdminAction?param=teacher"><span class="glyphicon glyphicon-plus-sign"></span> Add Teacher's</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-plus-sign"></span> Add Student's</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-plus-sign"></span> Add Non-Teaching Staff</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-plus-sign"></span> Add Parent's</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-plus-sign"></span> Add Branche's</a></li>
</ul>
</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#" style="color: white;"> Other Managment's <span class="caret"></a>
<ul class="dropdown-menu">
<li><a href="logout"><span class="glyphicon glyphicon-tasks"></span> Transport Managment</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-tasks"></span> Non-Teaching Staff Managment</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-tasks"></span> Furniture Managment</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-tasks"></span> Building Managment</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-user"></span> Complaints</a></li>
</ul>
</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#" style="color: white;"><span class="glyphicon glyphicon-user"></span> Hello, <s:property value="#session.user.articleUserName"/><span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="logout"><span class="glyphicon glyphicon-off"></span> Logout</a></li>
<li><a href="logout"><span class="glyphicon glyphicon-pencil"></span> Update Profile</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-user"></span> View your profile</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<link href="CustomCssAndScript/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="CustomCssAndScript/bootstrap/js/jquery.min.js"></script>
<script src="CustomCssAndScript/bootstrap/js/bootstrap.min.js"></script>
<html>
<head>
<script type="text/javascript">
function openMenu() {
var div1 = document.getElementById('anchor');
div1.style.display = "none";
var div = document.getElementById('menuBar');
div.style.display = "block";
}
function closeMenu() {
var div1 = document.getElementById('anchor');
div1.style.display = "block";
var div = document.getElementById('menuBar');
div.style.display = "none";
}
</script>
<meta name="viewport" content="width = device-width, initial-scale = 1">
<title>Insert title here</title>
</head>
<body>
<div class="container-fluid">
<a onclick="openMenu()" id="anchor" href="#"><span class="glyphicon glyphicon-tasks"> Menu</span></a>
<div class="navbar navbar-inverse col-lg-2 well" id="menuBar" style="display: none;">
<a class="pull-right" onclick="closeMenu()" href="#"><span class="glyphicon glyphicon-remove"></span></a><br/>
<div class="nav navbar-nav navbar-left">
<ul class="nav">
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#" style="color: blue;"> Dash Board<span class="caret"></a>
<ul class="dropdown-menu">
<li><a href="logout"><span class="glyphicon glyphicon-tasks"></span> Setting's</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-tasks"></span> Acadamic Detail's</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-tasks"></span> Privilege's</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-tasks"></span> Assign Cources</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-user"></span> Enquiry List</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-user"></span> Event Managment</a></li>
</ul>
</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#" style="color: blue;"> Academic's<span class="caret"></a>
<ul class="dropdown-menu">
<li><a href="viewProfile"><span class="glyphicon glyphicon-tasks"></span> Subjects and Batched</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-tasks"></span> Lession Planning</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-tasks"></span> Time Table</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-user"></span> Exams</a></li>
<li><a href="viewProfile"><span class="glyphicon glyphicon-user"></span> Notes and Assignment's</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
<?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="schoolStrutsConfig" namespace="/school" extends="struts-default">
<action name="addTeachersAdminAction" class="baci.portal.school.schoolActions.SchoolAdminAction" method="addPeople">
<result name="teacher">schoolHome.jsp</result>
<result name="student">addStudent.jsp</result>
<result name="nonteaching">addNonteaching.jsp</result>
<result name="parent">addParent.jsp</result>
<result name="branch">addBranch.jsp</result>
</action>
</package>
</struts>
<?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>
<!-- Login User -->
<package name="default" namespace="/" extends="struts-default">
<action name="login" class="baci.portal.actions.UserActions" method="login">
<result name="it">portal.jsp</result>
<result name="school">school/schoolHome.jsp</result>
<result name="input">index.jsp</result>
</action>
<!-- Posting Article -->
<action name="postArticle" class="baci.portal.actions.ArticleAction" method="postArticle">
<result name="success">portal.jsp</result>
</action>
<action name="viewArticle" class="baci.portal.actions.ArticleAction" method="viewArticle">
<result name="success">article.jsp</result>
</action>
<action name="comment" class="baci.portal.actions.ArticleAction" method="comment">
<result name="success">article.jsp</result>
</action>
<action name="articleSolution" class="baci.portal.actions.ArticleAction" method="articleSolution">
<result name="success">article.jsp</result>
</action>
<action name="viewProfile" class="baci.portal.actions.UserActions" method="viewProfile">
<result name="success">profile.jsp</result>
<result name="input">index.jsp</result>
</action>
<action name="logout" class="baci.portal.actions.UserActions" method="logout">
<result name="success">index.jsp</result>
<result name="input">index.jsp</result>
</action>
<action name="viewPublicProfile" class="baci.portal.actions.UserActions" method="viewPublicProfile">
<result name="success">publicProfile.jsp</result>
<result name="input">index.jsp</result>
</action>
<action name="signUp" class="baci.portal.actions.UserActions" method="signUp">
<result name="success">registration.jsp</result>
<result name="fail">index.jsp</result>
</action>
<action name="registerUser" class="baci.portal.actions.UserActions" method="registerUser">
<result name="success">index.jsp</result>
<result name="false">registration.jsp</result>
</action>
<action name="checkAval" class="baci.portal.actions.UserActions" method="checkAval">
</action>
<action name="homePage" class="baci.portal.actions.UserActions" method="homePage">
<result name="success">portal.jsp</result>
<result name="input">index.jsp</result>
</action>
<action name="publicProfile" class="baci.portal.actions.UserActions" method="publicProfile">
<result name="success">portal.jsp</result>
<result name="input">index.jsp</result>
</action>
</package>
<include file="/struts-school.xml"></include>
</struts>