Node.js 使用res.location和res.render
我让用户使用POST toNode.js 使用res.location和res.render,node.js,express,Node.js,Express,我让用户使用POST to/upload提交一个文件,然后我希望浏览器呈现index.mustache,并告诉浏览器位置是/。我尝试使用以下代码(在multer的onFileUploadComplete中)执行此操作: 它呈现索引,但浏览器将位置显示为/upload,而不是我想要的/。我做错了什么?(回答我自己的问题) 通过使用res.redirect('/')并将我的{options:'whatever'}逻辑放在别处,我能够解决我的问题。(回答我自己的问题) 通过使用res.redirect
/upload
提交一个文件,然后我希望浏览器呈现index.mustache
,并告诉浏览器位置是/
。我尝试使用以下代码(在multer的onFileUploadComplete
中)执行此操作:
它呈现索引
,但浏览器将位置显示为/upload
,而不是我想要的/
。我做错了什么?(回答我自己的问题)
通过使用res.redirect('/')
并将我的{options:'whatever'}
逻辑放在别处,我能够解决我的问题。(回答我自己的问题)
通过使用res.redirect('/')
并将我的{options:'whatever'}
逻辑放在别处,我能够解决我的问题
res.location('/');
res.render('index', {options: 'whatever'});