我将使用Spring Boot使用Spring Framework构建我的第一个使用Java的网站,并且它更容易构建它jar,但我有一些关于它的问题.
一般有什么不同?
在jar文件中,视图位于/resources/templates,但在war文件中,它在下面/webapp/WEB-INF/.
有什么区别?我可以jar在在线主机上部署吗?
我已经创建了登录并注册了 Express 和 Passport js。我想添加错误密码或电子邮件的消息。
在我的 index.js (main) 中添加了护照和正文解析器中间件,并引用了路由:
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// route files
let index = require("./routes/index");
let auth = require("./routes/auth");
app.use("/", index);
app.use("/auth", auth);
Run Code Online (Sandbox Code Playgroud)
我创建了护照配置:
const LocalStrategy = require("passport-local").Strategy;
const User = require("../models/User");
const config = require("../config/database");
const bcrypt = require("bcryptjs");
module.exports = function(passport) {
// Local Strategy
passport.use(
new LocalStrategy(
{
usernameField: "email",
passwordField: "password"
},
(username, password, done) => {
// Match Email
let query = { email: username };
User.findOne(query, function(err, user) …Run Code Online (Sandbox Code Playgroud) 我尝试使用Thymeleaf在Spring Boot中将CSS添加到我的HTML页面,在静态文件夹中添加CSS文件并以这种方式链接:
<link rel="stylesheet" th:href="@{/css/home.css}" href="../../css/home.css" />
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我想停止访问URL中的CSS和js,所以我将此方法添加到我的安全配置中:
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/resources/static/**"); // #3
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我什么是我的错误或是否需要任何配置?
spring ×2
spring-boot ×2
express ×1
jar ×1
java ×1
node.js ×1
passport.js ×1
thymeleaf ×1
war ×1