从JSP文件中提取CSS代码

从JSP文件中提取CSS代码,css,jsp,Css,Jsp,朋友 在我的JSP中,我有以下代码格式 <%@page isELIgnored="false" trimDirectiveWhitespaces="true" contentType="text/html;charset=UTF-8"%> <%@ taglib prefix="bs" tagdir="/WEB-INF/tags"%> <%@ taglib prefix="spring" uri="http://www.springframework.

朋友 在我的JSP中,我有以下代码格式

<%@page isELIgnored="false" trimDirectiveWhitespaces="true"
        contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="bs" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<bs:main title="Status">
        <bs:content>
                <bs:infoline />
                <div class="menubar">
                        <bs:menu />


        </bs:content>
</bs:main>
<script type="text/javascript">
$( document ).ready(function() {
        $('.save,.close').hide();
});

 $(document).ready(function () {
          var seconds = 5000; // time in milliseconds
            var reload = function() {
                  $.ajax({
                          url: 'editStatus.jsp',
                  cache: false,
                  success: function(data) {
                          $('#refreshDIV').html(data);
                  }
               });
             };
             setInterval(reload,seconds);
        });
var textValue = "";
$('.pencil').on('click', function(){
    textValue =  $(this).siblings('.textVal').text();
    $(this).siblings('.textVal').html("<input type='text' id='textVal' value='" + textValue + "' />");
    $(this).hide();
    $(this).siblings('.save, .close').show();
});

$('.save').on('click', function(){
    $(this).siblings('.textVal').html($(this).siblings('.textVal').find(':text').val());
    $(this).hide();
    $(this).siblings('.close').hide();
    $(this).siblings('.pencil').show();
});

$('.close').on('click', function(){
    $(this).siblings('.textVal').html(textValue)
    $(this).hide();
    $(this).siblings('.save').hide();
    $(this).siblings('.pencil').show();
});
</script>
<style type="text/css">
.textbox {
        height: 24px;
        width: 65px;
        line-height: 22px;
        padding: 3px
}

#textVal {
        width: 22px;
        margin-right: 4px
}

.icons {
        float: left;
        width: 20px;
        height: 20px;
}

.save,.close {
        display: none;
        width: 20px;
        height: 20px;
        float: left
}

.textVal {
        float: left;
        width: 35px;
        height: 20px;
        margin-right: 5px
}

.pencil {
        display: block
}

.red a {
        color: red
}
</style>

$(文档).ready(函数(){
$('.save,.close').hide();
});
$(文档).ready(函数(){
var seconds=5000;//以毫秒为单位的时间
var reload=函数(){
$.ajax({
url:'editStatus.jsp',
cache:false,
成功:功能(数据){
$('#refreshDIV').html(数据);
}
});
};
设置间隔(重新加载,秒);
});
var textValue=“”;
$('.pencil')。在('click',function()上{
textValue=$(this.sibbines('.textVal').text();
$(this.sibbines('.textVal').html(“”);
$(this.hide();
$(this).sides('.save,.close').show();
});
$('.save')。在('click',function()上{
$(this).sides('.textVal').html($(this).sides('.textVal').find(':text').val());
$(this.hide();
$(this.sides('.close').hide();
$(this.sides('.pencil').show();
});
$('.close')。在('click',function()上{
$(this).sides('.textVal').html(textValue)
$(this.hide();
$(this.sides('.save').hide();
$(this.sides('.pencil').show();
});
.文本框{
高度:24px;
宽度:65px;
线高:22px;
填充:3件
}
#textVal{
宽度:22px;
右边距:4px
}
.图标{
浮动:左;
宽度:20px;
高度:20px;
}
.保存,.关闭{
显示:无;
宽度:20px;
高度:20px;
浮动:左
}
textVal先生{
浮动:左;
宽度:35px;
高度:20px;
右边距:5px
}
.铅笔{
显示:块
}
.红色a{
颜色:红色
}
现在为了简单起见,我想在一个单独的css文件中包含以开头的所有代码,然后在上面的JSP中包含该css文件。 请建议最好的方法
谢谢

将标签的内容移动到名为“style.css”的文件中(或您喜欢的任何文件)。将此标记添加到JSP:

<link rel="stylesheet" type="text/css" href="style.css" />

将整个CSS代码移动到一个单独的.CSS文件中,并将该文件包含到php文件中。
包含CSS文件的代码:
PHP
HTML

这个问题没有问PHP。。。另外,最好将css文件作为一个单独的链接文档保存,这样可以减少html文件的大小,因为css可以独立缓存,所以html文件可能需要频繁下载。
Move the whole CSS code into a separate .css file and include  that file into your php file.

Code of Including CSS FILE:

PHP

<style>
<?php include 'CSS/main.css'; ?>
</style>


HTML
<link rel="stylesheet" href="http://www.mydomain.com/css/style.css">