小编fer*_*olg的帖子

使用Webpack将jQuery暴露给真正的Window对象

我不想将jQuery对象暴露给可在浏览器中的开发人员控制台中访问的全局窗口对象.现在在我的webpack配置中,我有以下几行:

plugins: [
                new webpack.ProvidePlugin({
                    $: 'jquery',
                    jQuery: 'jquery'
                })
            ]
Run Code Online (Sandbox Code Playgroud)

这些行将jQuery定义添加到我的webpack模块中的每个文件中.但是,当我构建项目并尝试在开发人员控制台中访问jQuery时,如下所示:

window.$;
window.jQuery;
Run Code Online (Sandbox Code Playgroud)

它说这些属性是未定义的......

有没有办法来解决这个问题?

javascript jquery webpack

102
推荐指数
5
解决办法
6万
查看次数

java.lang.IllegalStateException:在servlet中提交响应后无法转发

在我的项目中,我禁止用户每个页面只有他已经登录.这就是我写下面代码的原因.当我输入浏览器时,例如http:// localhost:8080/JSP1/Students,我来到login.jsp页面.但在输入loginid和密码后,只显示空白页http:// localhost:8080/JSP1/Logged,GlassFish表示存在异常

if (userPath.equals("/Students")){
        RequestDispatcher requestDispatcher = request.getRequestDispatcher("/Students.jsp");
        requestDispatcher.forward(request, response);
    }

java.lang.IllegalStateException: PWC1227: Cannot forward after response has been committed
Run Code Online (Sandbox Code Playgroud)

完整的doGet和doPost代码:

 @Override
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

     HttpSession ses = request.getSession();
     String login = (String)ses.getAttribute("login");
     String password = (String)ses.getAttribute("password");
     if ((login==null)|(password==null)){
         RequestDispatcher requestDispatcher = request.getRequestDispatcher("/login.jsp");
         requestDispatcher.forward(request, response);
     } 

     //Now we think that we are successfully logged in

    String userPath = request.getServletPath();
   // System.out.println(userPath);

    if (userPath.equals("/Login")){
        RequestDispatcher requestDispatcher = …
Run Code Online (Sandbox Code Playgroud)

java jsp servlets exception

6
推荐指数
1
解决办法
5万
查看次数

标签 统计

exception ×1

java ×1

javascript ×1

jquery ×1

jsp ×1

servlets ×1

webpack ×1