我是Web编程的新手,我想在网站上为注册用户创建一个配置文件页面,我无法理解。基本上只是用户的名字和他选择的图片。
那是我的个人资料。Handlebars代码:
<div class="row">
<div class="col-md-4">
<h1><%= user.firstName + " " + user.lastName %></h1>
<div class="thumbnail">
<img src="<%= user.avatar %>" alt="user profile image">
<div class="caption"><a href="mailto:<%= user.email %>"><%= user.email %></a></div>
</div>
</div>
</div>
<div class="col-md-8">
description
</div>
这是user.js模型:
var mongoose = require('mongoose');
var bcrypt = require('bcryptjs');
var passportLocalMongoose = require("passport-local-mongoose");
// User Schema
var UserSchema = mongoose.Schema({
username: {
type: String,
index:true
},
password: {
type: String
},
email: {
type: String
},
name: {
type: String
},
avatar: {
type: String
}
});
UserSchema.plugin(passportLocalMongoose);
var User = module.exports = mongoose.model('User', UserSchema);
发生的是profile.handlebars代码只是打印"&lt;%=用户....",因为它是字符串,我希望它打印现在登录的用户名称。
这些是打开个人资料时我遇到的错误。
URIError: Failed to decode param '%3C%=%20user.avatar%20%%3E'
at decodeURIComponent (<anonymous>)
at decode_param (I:ProgrammingGamon2node_modulesexpresslibrouterlayer.js:172:12)
at Layer.match (I:ProgrammingGamon2node_modulesexpresslibrouterlayer.js:148:15)
at matchLayer (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:574:18)
at next (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:220:15)
at Function.handle (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:174:3)
at router (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:47:12)
at Layer.handle [as handle_request] (I:ProgrammingGamon2node_modulesexpresslibrouterlayer.js:95:5)
at trim_prefix (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:317:13)
at I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:284:7
at Function.process_params (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:335:12)
at next (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:275:10)
at I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:635:15
at next (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:260:14)
at Function.handle (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:174:3)
at router (I:ProgrammingGamon2node_modulesexpresslibrouterindex.js:47:12)
预先感谢!
尝试使用{{user.avatar}}和{{user.email}}
&lt;%=%>符号在JSP中用于车把您应该在变量周围使用卷曲括号{{}}。