首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >引用错误:未读取视图文件夹中的.ejs文件

引用错误:未读取视图文件夹中的.ejs文件
EN

Stack Overflow用户
提问于 2019-06-11 03:08:01
回答 1查看 24关注 0票数 0

我试图在登录后重定向到反馈页面,但它只是加载了layout.ejs文件,并且在检查了查看页面的源代码后,它显示了一个引用错误。

feed.ejs文件

代码语言:javascript
复制
<nav class="navbar navbar-default">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
    </div>
    <div class="collapse navbar-collapse" id="navbar-collapse-1">
        <ul class="nav navbar-nav navbar-right">
            <li><a href="/company/changepassword">Change password</a></li>
            <li><a href="/company/logout">Logout</a></li>
        </ul>
    </div>
</nav>
 <h2 align="center">Industry Expectations & Feedback</h2>
        <hr>
        <br>
        <div class="container col-lg-4 col-md-5 col-sm-10 " style="margin-bottom:30px;">
    <label>Date: </label>
    <br>

    <label>Name of the Company: </label> <input type="text" class="form-control">
    <br>
    <label>Name of the Authorized Person:</label><input type="text" class="form-control">
    </div>


    <br>
    <br>
<div class="container">
<table class="table table-striped table-bordered">
  <thead>
    <tr>
      <th scope="col-md-4" >Description</th>
      <th scope="col-md-4"></th>

    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row" >1. Number Of years you have been Associated with our campus Placements:</th>
      <td>
      <label>1 Year</label><input type="radio" name="rad">
      &nbsp &nbsp
      <label>2 Year</label><input type="radio" name="rad">
      &nbsp &nbsp
      <label>3 Year</label><input type="radio" name="rad">
      &nbsp &nbsp
      <label>More Than 3 Years</label><input type="radio" name="rad">
      &nbsp &nbsp
      </td>

    </tr>
    <tr>
      <th scope="row">2. Average number of Students recruited by your company, through our campus:</th>
      <td>
      <label>Less than 10</label><input type="radio" name="rad1">
      &nbsp &nbsp
      <label>Less than 25</label><input type="radio" name="rad1">
      &nbsp &nbsp
      <label>Less than 50</label><input type="radio" name="rad1">
      &nbsp &nbsp
      <label>More Than 50</label><input type="radio" name="rad1">
      &nbsp &nbsp

      </td>

    </tr>
    <tr>
      <th scope="row">3. The course/courses from which you recruit our students regularly :</th>
      <td>
      <label>DAC</label><input type="checkbox">
      &nbsp &nbsp
      <label>WiMC</label><input type="checkbox">
      &nbsp &nbsp
      <label>DESD</label><input type="checkbox">
      &nbsp &nbsp
      <label>DSSD</label><input type="checkbox">
      &nbsp &nbsp
      <label>DAS</label><input type="checkbox">
      &nbsp &nbsp

      </td>

    </tr>
    <tr>
      <th scope="col-md-10" colspan="2">4. Quality of manpower recruited through Campus during the previous years :</th>


    </tr>
    <tr>
      <th scope="row">a) Technical Skills:</th>
      <td>
      <label>Excellent</label><input type="radio" name="rad2">
      &nbsp &nbsp
      <label>Good</label><input type="radio" name="rad2">
      &nbsp &nbsp
      <label>Average</label><input type="radio" name="rad2">
      &nbsp &nbsp
      <label>Poor</label><input type="radio" name="rad2">
      &nbsp &nbsp

      </td>

    </tr>
    <tr>
      <th scope="row">b) Communication Skills:</th>
      <td>
      <label>Excellent</label><input type="radio" name="rad3">
      &nbsp &nbsp
      <label>Good</label><input type="radio" name="rad3">
      &nbsp &nbsp
      <label>Average</label><input type="radio" name="rad3">
      &nbsp &nbsp
      <label>Poor</label><input type="radio" name="rad3">
      &nbsp &nbsp

      </td>

    </tr>
    <tr>
      <th scope="row">c) Overall Performance:</th>
      <td>
      <label>Excellent</label><input type="radio" name="rad4">
      &nbsp &nbsp
      <label>Good</label><input type="radio" name="rad4">
      &nbsp &nbsp
      <label>Average</label><input type="radio" name="rad4">
      &nbsp &nbsp
      <label>Poor</label><input type="radio" name="rad4">
      &nbsp &nbsp

      </td>

    </tr>
    <tr>
      <th scope="row">5. Attrition rate among the employees recruited through our campus:</th>
      <td>
      <label>Less than 1%</label><input type="radio" name="rad5">
      <label>Less than 5%</label><input type="radio" name="rad5">
      <label>Less than 10%</label><input type="radio" name="rad5">
      <label>Greater than 10%</label><input type="radio" name="rad5">

      </td>

    </tr>
    <tr>
      <th scope="row">6. How do you rate our campus Placement activity:</th>
      <td>
      <label>Excellent</label><input type="radio" name="rad6">
      &nbsp &nbsp
      <label>Good</label><input type="radio" name="rad6">
      &nbsp &nbsp
      <label>Average</label><input type="radio" name="rad6">
      &nbsp &nbsp
      <label>Poor</label><input type="radio" name="rad6">
      &nbsp &nbsp

      </td>



    </tr>
    <tr>
      <th scope="col-md-10" colspan="2">7.Any additional attributes expected from the students (Technical/Non-Technical):</th>


    </tr>
    <tr>
      <th scope="col-md-10" colspan="2"><textarea style="width:100%"></textarea></th>


    </tr>
    <tr>
      <th scope="col-md-10" colspan="2">8:Your comments and suggestions for improvement in C-DAC ACTS Courses:</th>
    </tr>
    </tr>
    <tr>
      <th scope="col-md-10" colspan="2"><textarea style="width:100%"></textarea></th>


    </tr>
        <tr>
      <th scope="col-md-10" colspan="2">9:Any suggestion for improvement of our campus activity:</th>
    </tr>
    </tr>
    <tr>
      <th scope="col-md-10" colspan="2"><textarea style="width:100%"></textarea></th>


    </tr>
  </tbody>
</table>
<br>
<center><input type ="submit" class=" btn-lg btn-success"/></center>
<br>
<br>
<br>
</div>

company.js文件

代码语言:javascript
复制
var express = require('express');
var router = express.Router();
router.get('/', function (req, res) {
    res.render('company/company', { error: req.flash('error') });
    //console.log(res.render('company/company', { error: req.flash('error') }));
});
router.get('/feedback', function (req, res) {
    res.render('company/feed', { error: req.flash('error') });
      });
router.post('/login', function (req, res) {
    var user = req.body.username;
    var pass = req.body.password;
    console.log(user);
    console.log(pass);
    res.redirect('/company/feedback');    
});

app.js文件具有所有的路由,并完美地完成了如下操作:

代码语言:javascript
复制
const createError = require('http-errors');
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const flash = require('connect-flash');
const bodyParser = require('body-parser');
const expressValidator = require('express-validator');
const session = require('express-session');
const expressLayout = require('express-ejs-layouts');
const app = express();
const cors = require('cors');


// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

app.use(logger('dev'));
// app.use(express.json());
// app.use(express.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(expressLayout);
app.use(session({ secret: 'surajbalwantshinde', resave: false, saveUninitialized: true}));
app.use(expressValidator());
app.use(cors());
app.use(flash());
// app.use(function(req, res){res.setHeader('Content-Type', 'text/plain');});

const companyRouter =require('./routes/company');
app.use('/company',companyRouter);

错误,它在视图源上闪烁:

代码语言:javascript
复制
<!-- <h1>E:\project pictures\StudentPortal\views\company\feed.ejs:203
    201| &lt;/div&gt;
    202| &lt;!-- &lt; &lt;div class=&#34;container-fluid&#34;&gt;
 &gt;&gt; 203|     &lt;% if(err.length&gt;0) {%&gt;
    204|     &lt;script&gt; $(function () { swal(&#34;&lt;%=err%&gt;&#34;, &#34;Try again!!&#34;, &#34;error&#34;) })&lt;/script&gt;
    205|     &lt;%}%&gt;
    206|     &lt;% if(msg.length&gt;0) {%&gt;

err is not defined</h1> -->
<!-- <h2></h2> -->
<!-- <pre>ReferenceError: E:\project pictures\StudentPortal\views\company\feed.ejs:203
    201| &lt;/div&gt;
    202| &lt;!-- &lt; &lt;div class=&#34;container-fluid&#34;&gt;
 &gt;&gt; 203|     &lt;% if(err.length&gt;0) {%&gt;
    204|     &lt;script&gt; $(function () { swal(&#34;&lt;%=err%&gt;&#34;, &#34;Try again!!&#34;, &#34;error&#34;) })&lt;/script&gt;
    205|     &lt;%}%&gt;
    206|     &lt;% if(msg.length&gt;0) {%&gt;

err is not defined
    at eval (eval at compile (E:\project pictures\StudentPortal\node_modules\ejs\lib\ejs.js:592:12), &lt;anonymous&gt;:11:8)
    at returnedFn (E:\project pictures\StudentPortal\node_modules\ejs\lib\ejs.js:623:17)
    at tryHandleCache (E:\project pictures\StudentPortal\node_modules\ejs\lib\ejs.js:251:36)
    at View.exports.renderFile [as engine] (E:\project pictures\StudentPortal\node_modules\ejs\lib\ejs.js:480:10)
    at View.render (E:\project pictures\StudentPortal\node_modules\express\lib\view.js:135:8)
    at tryRender (E:\project pictures\StudentPortal\node_modules\express\lib\application.js:640:10)
    at Function.render (E:\project pictures\StudentPortal\node_modules\express\lib\application.js:592:3)
    at ServerResponse.render (E:\project pictures\StudentPortal\node_modules\express\lib\response.js:1008:7)
    at ServerResponse.res.render (E:\project pictures\StudentPortal\node_modules\express-ejs-layouts\lib\express-layouts.js:77:18)
    at E:\project pictures\StudentPortal\routes\company.js:102:9
    at Layer.handle [as handle_request] (E:\project pictures\StudentPortal\node_modules\express\lib\router\layer.js:95:5)
    at next (E:\project pictures\StudentPortal\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (E:\project pictures\StudentPortal\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (E:\project pictures\StudentPortal\node_modules\express\lib\router\layer.js:95:5)
    at E:\project pictures\StudentPortal\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (E:\project pictures\StudentPortal\node_modules\express\lib\router\index.js:335:12)</pre> -->

我想要的输出应该是登录页面重定向到反馈页面上的反馈后正确的反馈表单,而不是一个空白页面.

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56532188

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档