Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
信
51rgb
網(wǎng)頁自動跳轉(zhuǎn)頁面的代碼在很多時候都非常的有用,下面的是兩個簡單的例子。僅供參考。
方案一,用<meta>里直接寫刷新語句:
<html>
<head>
<meta http-equiv="Content-Language" content="zh-CN">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<meta http-equiv="refresh" content="5;url=http://www.51rgb.com">
<title>html網(wǎng)頁自動跳轉(zhuǎn)代碼--西農(nóng)大網(wǎng)站</title>
</head>
<body>
測試:html網(wǎng)頁自動跳轉(zhuǎn)代碼<br/>
你可以在這里寫下你想的一切東西!<br />
如:西北農(nóng)林科技大學(xué)是一所985、211院校。<br />
</body></html>
方案二,用javascript腳本來跳轉(zhuǎn)
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>正在進(jìn)入西農(nóng)大網(wǎng)站</title>
</head>
<body>
<form name=loading>
<p align=center> <font color="#0066ff" size="2">正在進(jìn)入,請稍等</font><font color="#0066ff" size="2" face="Arial">...</font>
<input type=text name=chart size=46 style="font-family:Arial; font-weight:bolder; color:#0066ff; background-color:#fef4d9; padding:0px; border-style:none;">
<inputtype=text name=percent size=47 style="color:#0066ff; text-align:center; border-width:medium; border-style:none;">
<script>
var bar=0
var line="||"
var amount="||"
count
function count{
bar=bar+2
amount =amount + line
document.loading.chart.value=amount
document.loading.percent.value=bar+"%"
if (bar<99)
{setTimeout("count",100);}
else
{window.location =http://www.51rgb.com;}
}</script>
</p>
</form><p align="center">
測試:html網(wǎng)頁自動跳轉(zhuǎn)代碼<br/>
你可以在這里寫下你想的一切東西!<br />
如:西北農(nóng)林科技大學(xué)是一所985、211院校。<br /><br />
如果您的瀏覽器不支持跳轉(zhuǎn),<astyle="text-decoration: none" ><font color="#FF0000">請點(diǎn)這里</font></a>.</p>
</body>
</html>
↓↓↓
法1:使用onclick事件
<input type="button" value="按鈕" onclick="javascrtpt:window.location. />
或者直接使用button標(biāo)簽
<button onclick="window.location.>百度</button>
方法2:在button標(biāo)簽外套一個a標(biāo)簽
<a > <button>百度</button> </a>
或使用
<a ><input type="button" value='百度'></a>
方法3:使用JavaScript函數(shù)
pringBoot
springboot的目的是為了簡化spring應(yīng)用的開發(fā)搭建以及開發(fā)過程。內(nèi)部使用了特殊的處理,使得開發(fā)人員不需要進(jìn)行額外繁鎖的xml文件配置的編寫,其內(nèi)部包含很多模塊的配置只需要添加maven依賴即可使用,這項(xiàng)功能可謂對開發(fā)人員提供了大大的好處。使用springboot只需要簡單配置一下就可以完成之前復(fù)雜的配置過程。可以到https://start.spring.io/此網(wǎng)站上,下載一個最簡單的springboot應(yīng)用,然后一步一步實(shí)現(xiàn)自已的應(yīng)用。
可以看出當(dāng)前的穩(wěn)定版本為2.1.0,點(diǎn)擊Generate Project 按鈕,即可下載一個可用的springboot應(yīng)用。
這個是我下載下來后,雙擊后出來的。可以看出以工程是一個基于maven的項(xiàng)目。你可以將其解壓到任何一個目錄下,通過eclipse或其他IDE進(jìn)行導(dǎo)入后運(yùn)行,eclipse導(dǎo)入流程為File->import->maven->existing maven projects,查找到自己的項(xiàng)目目錄。也可以基于此工程來建立自已的maven項(xiàng)目。
下面以建立自己的maven項(xiàng)目
建立自己的springboot項(xiàng)目
在建立項(xiàng)目時,可以創(chuàng)建一個多模塊聚合項(xiàng)目,即在創(chuàng)建項(xiàng)目時選中
選擇為pom。
創(chuàng)建后的工程結(jié)構(gòu)為
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.0.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties>
將此段代碼復(fù)制到 spring-boot-study工程中的pom文件中
將下面的依賴復(fù)制到spring-boot-web工程中的pom文件中
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
eclipse自動完成項(xiàng)目工程的配置。完成后項(xiàng)目中所有需要依賴的jar包自動配置完成。
@SpringBootApplication @RestController public class WebApplication { @RequestMapping("/hello") public String helloWorld() { return "Hello World"; } public static void main(String[] args) { SpringApplication.run(WebApplication.class, args); } }
HelloWold就已經(jīng)完成后。可以在瀏覽器中輸入localhost:8080/hello即可看到效果
springboot默認(rèn)啟動后的端口為8080,但可以在application.properties文件中進(jìn)行修改。
server.port=9001
將端口修改為9001,重新啟動項(xiàng)目后,在瀏覽器中輸入入localhost:9001/hello同樣可以看到相同的結(jié)果。
<!-- 加入thymeleaf的支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
但在Spring Boot項(xiàng)目中,一般src/main/resources/static目錄用于存放各類靜態(tài)資源文件,例如css、js和image等。src/main/resources/templates用于存放頁面文件,例如html,jsp等。所以在spring-boot-web中的resources目錄下創(chuàng)建static目錄與templates目錄,并將相應(yīng)的資源文件放置在各自的目錄下。
配置thymeleaf
#thymeleaf spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html spring.thymeleaf.mode=HTML spring.thymeleaf.encoding=UTF-8 spring.thymeleaf.servlet.content-type=text/html spring.thymeleaf.cache=false
html文件修改,增加xmlns:th="http://www.thymeleaf.org" 屬性,資源文件的引入要修改。
<link href="../static/css/style.css" th:href="@{/css/style.css}" rel="stylesheet" /> <link href="../static/css/login.css" th:href="@{/css/login.css}" rel="stylesheet" />
然后編寫 java代碼
@Controller public class IndexController { @RequestMapping("/") public String index() { return "login"; } }
重新啟動程序,訪問localhost:9001/就可成功跳轉(zhuǎn)至login.html登陸界面上。
注:thymeleaf對html標(biāo)簽要求很嚴(yán)格,每一個標(biāo)簽都需要成對出現(xiàn)。
調(diào)試過程中遇到下面異常信息
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [login], template might not exist or might not be accessible by any of the configured Template Resolvers at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:362) [thymeleaf-spring5-。。。。。。。。。。。
因?yàn)殄e將templates寫成templatse導(dǎo)致。
至此實(shí)現(xiàn)從后端服務(wù)訪問到登陸界面的搭建,還沒有具體登陸邏輯實(shí)現(xiàn)。
*請認(rèn)真填寫需求信息,我們會在24小時內(nèi)與您取得聯(lián)系。