在线等 急! 报错javax.servlet.ServletException: java.lang.NoSuchMethodError:

wt12735 wt12735 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
请看一下报错:

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.NoSuchMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:274)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NoSuchMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
org.apache.jsp.login_jsp._jspInit(login_jsp.java:22)
org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.13

我的数据库:mysql5.0,以及所有的JSP页面 都用“gbk”,我的上传代码:uploadFileServlet.java 代码如下,请问问题出在哪?怎么改?:

package pageconnection;


import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import com.jdbc.Jdbc;


public class UploadFileServlet extends HttpServlet{


protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

String type = "" ;
String titleName ="" ;
String fileName = "";
Jdbc jdbc ;
String path ="";
request.setCharacterEncoding("gbk");

path = request.getRealPath("/image/");
// path = path.trim() ;
//path = "d:/tempImage" ;
// path = "E:\\java\\workspace2\\page\\WebContent\\image" ;
DiskFileItemFactory factory = new DiskFileItemFactory();

factory.setRepository(new File(path));
factory.setSizeThreshold(1024 * 1024);

ServletFileUpload upload = new ServletFileUpload(factory);


try
{
List<FileItem>list = upload.parseRequest(request);
for(FileItem item:list){
if(item.isFormField()){
String name = item.getFieldName();

String value = item.getString();
// String str = new String(request.getParameter("title").getBytes("ISO-8859-1"),"UTF-8");

String value2 = new String(value.getBytes("ISO-8859-1"),"gbk") ;
request.setAttribute(name, value2);
System.out.println(value);
}
else{
String name = item.getFieldName();
String value = item.getName();
System.out.println(value);
File tempFile = new File(item.getName());

fileName = tempFile .getName() ;

request.setAttribute(name, fileName);
System.out.println(fileName);

OutputStream os = new FileOutputStream(new File(path,fileName));
InputStream is = item.getInputStream();

byte[] buffer = new byte[4096];
int length = 0;
while((length = is.read(buffer))>0){
os.write(buffer,0,length);
}
os.close();
is.close();
}
}
}
catch(Exception e){
e.printStackTrace();
}


jdbc = new Jdbc() ;
type = (String)request .getAttribute("select1") ;

titleName = (String )request.getAttribute("titlename");
System.out.println(titleName);
//fileName = type + fileName ;

jdbc .insertNewImage(fileName, titleName, type,new Date().toLocaleString()) ;

request.getRequestDispatcher("/pages/admin/result.html").forward(request, response);
}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
doPost(request, response) ;
}

}
...全文

相关推荐

WEB开发报错处理集锦

Hibernate JSP Struts 等 多个软件开发中报错处理集锦 对初学者 初开发者 都有很大帮助 希望大家在开发中出错的开一下再下来看一看 应该很有用的

canghaizixia

ssh框架错误总结

ssh框架错误总结

yxy_327

Java学生信息管理系统源码解析与毕设实战指南

Java Web 应用开发中,学生信息管理系统是理解 MVC 分层架构、数据库设计与 Servlet 生命周期的经典入门场景。其核心在于掌握 JDBC 连接配置、UTF-8 字符集统一、预编译 SQL 防注入等基础原理,具备真实业务字段建模(如学籍状态、班级关联)和完整 CRUD 流程实现能力。该系统不仅支撑高校毕业设计答辩所需的代码可讲性与结构规范性,也适用于 Java 初学者构建可调试、可扩展的最小可行工程。本文围绕 `java学生信息管理系统源码` 展开,详解数据库脚本执行顺序、IDEA 导入配置、中

井言7

SSM+微信小程序物业系统实战:从数据库建模到前后端数据同步

Spring MVC 是 Java Web 开发的经典分层架构,其核心在于清晰分离控制器、服务与数据访问层,支撑高可维护性业务系统。在微信小程序与后台管理双端协同场景中,SSM 框架凭借显式配置、可控请求链路和灵活 SQL 控制能力,成为中小规模物业系统的优选技术栈。项目通过带外键约束的 MySQL 数据库建模、MyBatis 手写 JOIN 查询、@RequestParam 适配小程序表单提交、Session-Based 权限拦截及乐观锁保障数据一致性,完整呈现了传统 SSM 架构下小程序项目的工程落地路

抹茶柚子冰

高清山西煤矿分布图矢量格式免费下载

高清山西煤矿分布图矢量格式免费下载

qq_33296528
评论 6
收藏 已收藏
分享
返回顶部
wt12735
Web 开发 81,108 成员 341,721 内容