页面html如下:
<div class='control-group'>
<label class='control-label' for='email'>电子邮件</label>
<div class='controls'>
<input class='input-xlarge readonly' id='email' name='email' size='30' type='text' readonly='true' value='<%= email %>' />
</div>
</div>
<div class='control-group'>
<label class='control-label' for='profile'>个人简介</label>
<div class='controls'>
<% if(locals.profile){ %>
<textarea class='input-xlarge' id='profile' name='profile' rows='4'><%= profile %></textarea>
<% }else{ %>
<textarea class='input-xlarge' id='profile' name='profile' rows='4'></textarea>
<% } %>
</div>
</div>
nodejs代码如下:
var method = req.method.toLowerCase();
if (method !== 'post') {
get_user_by_id(req.session.user._id, function (err, user) {
if (err) {
return next(err);
}
if (req.query.save === 'success') {
user.success = '保存成功。';
}
user.error = null;
return res.render('user/setting', user);
});
return;
}
nodejs中并没有render各个值进去啊,只是render了user对象。是如何取到值的呢?登陆的时候存到session中了吗?