css - 启用将 css 加载到 maven 项目的 xhtml 页面中
问题描述
我在我的项目中有一个像这样定义的标题,它包括模板所需的所有资产:
header.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:panelGroup>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width,initial-scale=1,user-scalable=0,minimal-ui" />
<meta content="Admin Dashboard" name="description" />
<meta content="ThemeDesign" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="shortcut icon" href="../assets/images/favicon.ico" />
<link href="../assets/css/bootstrap.min.css" rel="stylesheet"
....
</head>
</h:panelGroup>
</ui:composition>
我将它包含在我的 xhtml 页面中,如下所示:
登录.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!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"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title>Login</title>
</head>
<body>
<ui:include src="/template/header.xhtml" />
<!--><ui:insert name="menu" /><!-->
<!--><ui:insert name="content" /><!-->
<div class="accountbg">
<div class="content-center">
<div class="content-desc-center">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-5 col-md-8">
<div class="card">
<div class="card-body">
<h3 class="text-center mt-0 m-b-15"><a href="index.html"
class="logo logo-admin"><img src="../assets/images/logo-dark.png" height="30"
alt="logo" /></a></h3>
<h4 class="text-muted text-center font-18"><b>Sign In</b></h4>
<div class="p-2">
<h:form class="form-horizontal m-t-20" >
<div class="form-group row">
<div class="col-12"><h:inputText class="form-control" type="text" required="" value="#{loginManagedBean.emailField}" placeholder="Username" /></div>
</div>
<div class="form-group row">
<div class="col-12">
<h:inputSecret class="form-control" required="" value="#{loginManagedBean.passworField}" placeholder="Password" /></div>
</div>
<div class="form-group text-center row m-t-20">
<div class="col-12">
<button class="btn btn-primary btn-block waves-effect waves-light" action="#{loginManagedBean.login()}">
Log In
</button>
</div>
</div>
<div class="form-group m-t-10 mb-0 row">
<div class="col-sm-7 m-t-20"><a href="passwordRecovery.xhtml"
class="text-muted"><i class="mdi mdi-lock"></i> Forgot your
password?</a></div>
</div>
</h:form>
</div>
</div>
</div>
</div>
</div><!-- end row -->
</div>
</div>
</div>
</div>
</body>
</html>
登录页面在应用所有 css 的情况下呈现良好,但是当我在 resetpassword.xhtml 中复制相同的操作时,页面呈现完全没有 css,但<img>
标签正在正确加载 logo.png。现在我这些是我发现自己做很多多余的步骤:
- 清洁和重建工作组。
- maven force 更新项目。
- 从 Maven 中取出耳朵并清洁服务器。
- 重新启动 maven 并重新发布 ear 项目。
重置密码.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!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"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title>Reset Password</title>
</head>
<body>
<ui:include src="/template/header.xhtml" />
<div class="accountbg">
<div class="content-center">
<div class="content-desc-center">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-5 col-md-8">
<div class="card">
<div class="card-body">
<h3 class="text-center mt-0 m-b-15"><a href="Login.xhtml"
class="logo logo-admin"><img src="../assets/images/logo-dark.png" height="30"
alt="logo" /></a></h3>
<h4 class="text-muted text-center font-18"><b>Reset Password</b></h4>
<div class="p-3">
<h:form class="form-horizontal m-t-20">
<div class="alert alert-danger alert-dismissible"><button type="button"
class="close" data-dismiss="alert" aria-hidden="true">×</button>
Enter your <b>Email</b> and instructions will be sent to you!</div>
<div class="form-group row">
<div class="col-12"><h:inputText class="form-control" type="email" required="" value="#{resetPassword.emailField}" placeholder="Email" /></div>
</div>
<div class="form-group text-center row m-t-20">
<div class="col-12">
<button class="btn btn-primary btn-block waves-effect waves-light" action="#{resetPassword.resetPasswordAction()}">Send Email</button>
</div>
</div>
</h:form>
</div>
</div>
</div>
</div>
</div><!-- end row -->
</div>
</div>
</div>
</div>
</body>
</html>
解决方案
推荐阅读
- node.js - 我是否需要将房间中的当前用户存储在数据库中?套接字.io
- batch-file - Windows cmd批处理 - 将文件的属性设置为变量
- c - C 结构 TriplePointer 内存分配
- c# - C# 使用图表在坐标系上放置 XY 点?
- sql - 处理 AI Platform 批处理结果 BigQuery
- webpack - Webpack v4 长期支持?
- r - 使用 tidymodels 运行多个回归模型
- android - 无法使用证书 (.cer) 验证签名 XML
- angular - TypeError:无法读取未定义的属性'of'
- c# - 另一个“运行所选代码生成器时出错:”和“包还原失败。回滚包更改“(解决方案名称)