系统找不到指定的文件。
/*
运行报错:
六月 28, 2020 10:57:28 下午 org.apache.catalina.core.StandardContext backgroundProcess
警告: 异常处理加载程序[WebappLoader[/shop]]后台进程
java.lang.IllegalStateException: java.io.FileNotFoundException: D:\apache-tomcat-8.5.53\webapps\shop\WEB-INF\lib\commons-fileupload-1.2.1.jar (系统找不到指定的文件。)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:100)
at org.apache.catalina.webresources.AbstractArchiveResourceSet.getResource(AbstractArchiveResourceSet.java:257)
at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:281)
at org.apache.catalina.webresources.Cache.getResource(Cache.java:62)
at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:216)
at org.apache.catalina.webresources.StandardRoot.getClassLoaderResource(StandardRoot.java:225)
at org.apache.catalina.loader.WebappClassLoaderBase.modified(WebappClassLoaderBase.java:730)
at org.apache.catalina.loader.WebappLoader.modified(WebappLoader.java:347)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:291)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5539)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1385)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1385)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1353)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: D:\apache-tomcat-8.5.53\webapps\shop\WEB-INF\lib\commons-fileupload-1.2.1.jar (系统找不到指定的文件。)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:197)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:182)
at org.apache.catalina.webresources.AbstractArchiveResourceSet.openJarFile(AbstractArchiveResourceSet.java:308)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:96)
... 14 more
*/
package com.imooc.web.action;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.imooc.domain.User;
import com.imooc.service.UserService;
import com.imooc.service.impl.UserServiceImpl;
/**
* Servlet implementation class UserServlet
*/
@WebServlet("/UserServlet")
public class UserServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//接收参数
String methodName = request.getParameter("method");
//判断
if("login".equals(methodName)) {
login(request,response);
}
}
/**
* UserSevlet中登录的方法
* @param request
* @param response
* @throws IOException
* @throws ServletException
*/
private void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//接收用户名和密码
String username = request.getParameter("username");
String password = request.getParameter("password");
System.out.println(username+" "+password);
//数据的封装
User user = new User();
user.setUsername(username);
user.setPassword(password);
//处理数据
UserService userService = new UserServiceImpl();
User existUser = userService.login(user);
//根据处理结果,完成页面跳转
if(existUser == null) {
//登录失败
//返回到登录页
request.setAttribute("msg", "用户名或密码错误!!!");
request.getRequestDispatcher("/admin/login.jsp").forward(request, response);
}else {
//登录成功
//将用户信息进行保存,进行页面跳转
request.getSession().setAttribute("existUser", existUser);
response.sendRedirect(request.getContextPath()+"/admin/category_list.jsp");
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
package com.imooc.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.imooc.dao.UserDao;
import com.imooc.domain.User;
import com.imooc.utils.JDBCUtils;
public class UserDaoImpl implements UserDao {
@Override
public User login(User user) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
// 获得连接
conn = JDBCUtils.getConnection();
// 编写SQL
String sql = "select * from user where username = ? and password = ?";
// 预编译SQL
pstmt = conn.prepareStatement(sql);
// 设置参数
pstmt.setString(1, user.getUsername());
pstmt.setString(2, user.getPassword());
// 执行
rs = pstmt.executeQuery();
if(rs.next()) {
User existUser = new User();
existUser.setUid(rs.getInt("uid"));
existUser.setUsername(rs.getString("username"));
existUser.setPassword(rs.getString("password"));
return existUser;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
// 释放资源
JDBCUtils.release(rs, pstmt, conn);
}
return null;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>欢迎使用油画商城</title>
<meta name="keywords" content="HTML5 Bootstrap 3 Admin Template UI Theme" />
<meta name="description" content="AbsoluteAdmin - A Responsive HTML5 Admin UI Framework">
<meta name="author" content="AbsoluteAdmin">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/assets/skin/default_skin/css/theme.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/assets/admin-tools/admin-forms/css/admin-forms.css">
<link rel="shortcut icon" href="${pageContext.request.contextPath }/assets/img/favicon.ico">
</head>
<body class="external-page external-alt sb-l-c sb-r-c">
<div id="main" class="animated fadeIn">
<section id="content_wrapper">
<section id="content">
<div class="admin-form theme-info mw500" id="login">
<div class="content-header">
<h1>油画商城</h1>
<p class="lead">欢迎使用油画商城自动化管理系统</p>
<font color="red">${ msg }</font>
</div>
<div class="panel mt30 mb25">
<form method="post" action="${pageContext.request.contextPath }/UserServlet" id="contact">
<input type="hidden" name="method" value="login"/>
<div class="panel-body bg-light p25 pb15">
<div class="section">
<label for="sn" class="field-label text-muted fs18 mb10">名称</label>
<label for="sn" class="field prepend-icon">
<input type="text" name="username" id="username" class="gui-input" placeholder="请输入名称...">
<label for="sn" class="field-icon">
<i class="fa fa-user"></i>
</label>
</label>
</div>
<div class="section">
<label for="password" class="field-label text-muted fs18 mb10">密码</label>
<label for="password" class="field prepend-icon">
<input type="password" name="password" id="password" class="gui-input" placeholder="请输入密码...">
<label for="password" class="field-icon">
<i class="fa fa-lock"></i>
</label>
</label>
</div>
</div>
<div class="panel-footer clearfix text-center">
<button type="submit" class="button btn-primary mr10"> 登陆 </button>
</div>
</form>
</div>
</div>
</section>
</section>
</div>
<script src="vendor/jquery/jquery-1.11.1.min.js"></script>
<script src="vendor/jquery/jquery_ui/jquery-ui.min.js"></script>
<script src="assets/js/utility/utility.js"></script>
<script src="assets/js/demo/demo.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<default-config>
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql:///shop</property>
<property name="user">root</property>
<property name="password">root123</property>
</default-config>
</c3p0-config>
正在回答
同学你好,报错提示找不到指定的文件,如:
建议同学检查一下WEB-INF目录下的lib包中是否有commons-fileupload-1.2.1.jar的jar包,如果没有,建议同学添加再试试。
祝:学习愉快~
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星