今天早搭一个web项目时,我的index.html文件由三个html用<frame>组成
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>首页</title>
</head>
<frameset rows="100,*" cols="*" scrolling="No" framespacing="0" frameborder="no" border="0">
<frame src="head.html" name="headmenu" id="mainFrame" title="mainFrame"/><!-- 引用头部 -->
<!-- 引用左边和主体部分 -->
<frameset rows="100*" cols="220,*" scrolling="No" framespacing="0" frameborder="no" border="0">
<frame src="left.html" name="leftmenu" id="mainFrame" title="mainFrame"/>
<frame src="main.html" name="main" scrolling="yes" noresize="noresize" id="rightFrame" title="rightFrame"/>
</frameset>
</frameset&

在使用SpringMVC构建web项目时,index.html通过frame标签引用head.html、left.html和main.html。当将这些HTML文件放在templates文件夹下并尝试访问时,出现404错误。原因在于Thymeleaf模板引擎的配置,templates下的HTML不能直接访问,需要通过controller。解决方案是将HTML文件移动到static文件夹下,之后能够正常访问。
最低0.47元/天 解锁文章
1014





