对于<welcome-file-list>设置主页后无法引用CSS的问题

在eclipse中对web程序进行开发,当把非webroot根目录下的文件设置为主页时,如果对css目录采用相对路径,将会无法应用,这时需要对文件的相对路径进行修改,如果是jsp文件,直接加头文件对目录进行设置:

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


在原来的css目录中加上<%=basePath%>


而如果是html,则复制过来变成jsp,记得把头文件改成<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>。否则会乱码。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
把下面的格式改成代码形式,并每行进行一局注释#!/usr/bin/env python # -*- coding: utf-8 -*- import time def read_file(file_path): test_file = open(file_path, "r") test_words = test_file.read() test_file.close() return test_words def save_result(result, file_path): output_file = open(file_path, "w") output_file.write(result) print("Save completed") def count_word(input_str): count_words = input_str.split() count_dict = {} for word in count_words: word = word.lower() if word not in count_dict.keys(): count_dict[word] = 1 else: count_dict[word] += 1 return count_dict def get_min(count_dict): min_count = min(count_dict.values()) min_words = [] for word, count in count_dict.items(): if count == min_count: min_words.append(word) return min_words, min_count def get_localtime(): localtime = time.localtime() return time.strftime("%H:%M:%S", localtime) def convert2str(*args): output_str = "The words and corresponding times:\n" for arg in args: try: if type(arg) == list: tmp_str = " ".join(arg) output_str += tmp_str elif type(arg) == int or type(arg) == str: output_str += " : " output_str += str(arg) except: print("Error, unknown type:", type(arg)) return output_str if __name__ == '__main__': test_words = read_file("test_words.txt") count_result = count_word(test_words) min_words, min_count = get_min(count_result) print("check_time:", get_localtime()) print("check_result:", min_words, min_count) output_str = convert2str(min_words, min_count) save_result(output_str, "test_word_result.txt")
03-22
```html <!DOCTYPE html> <html> <head> <title>My Website</title> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <header> <h1>Welcome to my website</h1> <nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> </nav> </header> <main> <section> <h2>About me</h2> <p>Hi, my name is John and I'm a web developer.</p> </section> <section> <h2>My projects</h2> <ul> <li><a href="#">Project 1</a></li> <li><a href="#">Project 2</a></li> <li><a href="#">Project 3</a></li> </ul> </section> </main> <footer> <p>© 2021 My Website</p> </footer> </body> </html> ``` ```html <!-- 定义文档类型 --> <!DOCTYPE html> <!-- 定义html标签 --> <html> <head> <!-- 定义网页标题 --> <title>My Website</title> <!-- 定义字符编码 --> <meta charset="UTF-8"> <!-- 引入外部样式表 --> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <!-- 定义页眉 --> <header> <!-- 定义一级标题 --> <h1>Welcome to my website</h1> <!-- 定义导航栏 --> <nav> <ul> <!-- 定义导航栏选项 --> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> </nav> </header> <!-- 定义主要内容 --> <main> <!-- 定义一个区块 --> <section> <!-- 定义二级标题 --> <h2>About me</h2> <!-- 定义段落 --> <p>Hi, my name is John and I'm a web developer.</p> </section> <!-- 定义一个区块 --> <section> <!-- 定义二级标题 --> <h2>My projects</h2> <!-- 定义无序列表 --> <ul> <!-- 定义列表项 --> <li><a href="#">Project 1</a></li> <li><a href="#">Project 2</a></li> <li><a href="#">Project 3</a></li> </ul> </section> </main> <!-- 定义页脚 --> <footer> <!-- 定义段落 --> <p>© 2021 My Website</p> </footer> </body> <!-- 定义html结束标签 --> </html> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值