myeclipse的一个错误javax.servlet.ServletException

some3one 2011-01-06 04:55:02
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: Servlet.init() for servlet jsp threw exception
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NoClassDefFoundError
org.apache.jasper.compiler.JspRuntimeContext.<init>(JspRuntimeContext.java:104)
org.apache.jasper.servlet.JspServlet.init(JspServlet.java:77)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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

================================================
以前也遇到过,后来不知道怎么解决的,现在又出现了,找了好久都没能解决啊,求解啊
...全文
838 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
TzSword 2011-01-07
  • 打赏
  • 举报
回复
我在网上搜的解决方案是更换JRE版本。然后我在myeclipse中的project菜单中的property中,更改JDK compliance分别为1.3,1.4,5.0都不行。在myeclipse中的windows菜单中的preference中修改jre为5.0也不行。用myeclipse自带的JRE也不行。



最终结果是Tomcat下面设置的JDK和应用程序使用的JDK版本不一致所致!!!

解决办法:
1.打开MyEclipse
2.Window
3.Preferences
4.选择Java节点
5.Installed JREs
6.可以看到当前使用的JVM是什么版本,路径在哪里,现在我们要改正和Tomcat一样的虚拟机.
6.Edit
7.JRE home directory
8.Browse 找到:C:\Sun\SDK\jdk\jre(找到你的安装目录)
9.ok
搞定了.!

分析:
比如,你項目中的是JRE5.0但compile是JRE6.0則出現上述錯誤。或者版本不一致!


答案来自http://www.javaeye.com/topic/576365
some3one 2011-01-07
  • 打赏
  • 举报
回复
我是在用structs框架做web项目,因为在部署时有5楼的那个问题,在显示jsp页面时就报了1楼的错误,java新手求教啊
some3one 2011-01-07
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 tzsword 的回复:]
引用 1 楼 tzsword 的回复:
这个错误表示 你缺少servlet-api.jar

这个包在Myeclipse下面有 Tomcat下面也有
[/Quote]

这个包不需要手动添加的吧,默认有的吧,我tomcat启动好了,但启动后部署项目貌似有个问题,会不会是那个的原因

2011-1-7 8:39:50 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\Java\jdk1.5.0_06\bin;D:\apache-tomcat-5.5.20\bin
2011-1-7 8:39:50 org.apache.coyote.http11.Http11BaseProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2011-1-7 8:39:50 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1843 ms
2011-1-7 8:39:50 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2011-1-7 8:39:50 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.20
2011-1-7 8:39:50 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
2011-1-7 8:39:52 org.apache.catalina.core.ApplicationContext log
信息: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]]
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
2011-1-7 8:40:00 org.apache.commons.modeler.Registry registerComponent
严重: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/dangdang,J2EEApplication=none,J2EEServer=none
2011-1-7 8:40:01 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2011-1-7 8:40:01 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2011-1-7 8:40:02 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2011-1-7 8:40:02 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2011-1-7 8:40:02 org.apache.coyote.http11.Http11BaseProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2011-1-7 8:40:03 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-1-7 8:40:03 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/140 config=null
2011-1-7 8:40:03 org.apache.catalina.storeconfig.StoreLoader load
信息: Find registry server-registry.xml at classpath resource
2011-1-7 8:40:03 org.apache.catalina.startup.Catalina start
信息: Server startup in 13110 ms
2011-1-7 8:40:22 org.apache.catalina.startup.HostConfig checkResources
信息: Reloading context [/dangdang]
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
2011-1-7 8:40:27 org.apache.commons.modeler.Registry registerComponent
严重: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/dangdang,J2EEApplication=none,J2EEServer=none
TzSword 2011-01-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 tzsword 的回复:]
这个错误表示 你缺少servlet-api.jar
[/Quote]
这个包在Myeclipse下面有 Tomcat下面也有
Jlins 2011-01-06
  • 打赏
  • 举报
回复
因为你没有引入tomcat服务器 所以缺少了 servlet-api.jar
happyfmy 2011-01-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 tzsword 的回复:]
这个错误表示 你缺少servlet-api.jar
[/Quote]
+1
TzSword 2011-01-06
  • 打赏
  • 举报
回复
这个错误表示 你缺少servlet-api.jar
JSP100选择题 适合考前练习 1 J2EE 中,()类的()方法用于创建对话。(选择一项) a) HttpServletRequest、getSession b) HttpServletResponse、newSession c) HtttpSession、newInstance d) HttpSession、getSession 2 给定一个 Servlet 的doGet方法中的代码片段,如下: request.setAttribute(“name”,”zhang”); response.sendRedirect(“http://localhost:8080/servlet/MyServlt”); 那么在 MyServlet 中可以使用()方法把属性 name的值取出来。(选择一项) a) String str=request.getAttribute(“name”); b) String str=(String)request.getAttribute(“name”); c) Object str=request.getAttribute(“name”); d) 无法取出来 3.在Servlet里,能实现重定向的方法有()。(选择两项) A.运用javax.servlet.http.HttpServletRequest接口的sendRedirect方法 B.运用javax.servlet.http.HttpServletResponse接口的sendRedirect方法 C.运用javax.servlet.RequestDispatcher接口的forward方法 D.运用javax.servlet.ResponseDispatcher接口的forward方法 4.利用MyEclipse开发Servlet,下列说法正确的是( )。(只选两项) A. MyEclipse可自动产生web.xml B. MyEclipse不能自动产生web.xml,需要手工编写 C.可利用MyEclipse自带的Tomcat作为Servlet容器 D. MyEclipse没有自带Tomcat,需要自己安装配置。 5.编写Servlet 的doPost方法时,需要抛出异常为()。(只选一项) A.ServletException, IOException B.ServletException, RemoteException C.HttpServletException, IOException D.HttpServletException, RemoteException 6.有关会话跟踪技术描述正确的是()。(选择三项) A.Cookie是Web服务器发送给客户端的一小段信息,客户端请求时,可以读取该信息发送到服务器端 B.关闭浏览器意味着会话ID丢失,但所有与原会话关联的会话数据仍保留在服务器上,直至会话过期 C.在禁用Cookie时可以使用URL重写技术跟踪会话 D.隐藏表单域将字段添加到HTML表单并在客户端浏览器中显示 …………
import java.io.IOException; import java.io.PrintWriter; import java.util.*; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * @author xiaoq * */ public class AddVoteServlet extends HttpServlet { /** * Constructor of the object. */ public AddVoteServlet() { super(); } /** * Destruction of the servlet.
*/ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doPost method of the servlet.
* * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=GBK"); PrintWriter out = response.getWriter(); out.println(""); out.println(" add vote"); out.println(" "); String title=request.getParameter("title"); String stile=request.getParameter("stile"); String startTime=request.getParameter("startyear")+"-"+request.getParameter("startmonth")+"-"+ request.getParameter("startday"); String endTime=request.getParameter("endyear")+"-"+request.getParameter("endmonth")+"-"+ request.getParameter("endday"); String active=request.getParameter("active"); int newActive=Integer.parseInt(active); /**test out.println(title+""+stile+""+endTime+""+startTime+""+newActive+""); */ Questions question=new Questions(); question.setTitle(title); question.setStyle(stile); question.setStrStartime(startTime); question.setStrEndtime(endTime); question.setActive(newActive); int n=Integer.parseInt(request.getParameter("n")); Collection items=new ArrayList();
​ 博主介绍:✌在职Java研发工程师、专注于程序设计、源码分享、技术交流、专注于Java技术领域和毕业设计✌项目名称基于Web的酒店客房管理系统的设计与实现系统说明3.2.1  用户模块功能分析前台模块应主要包括用户登录模块、用户注册模块、查看客房信息模块、客房预定 模块、用户留言模块、充值模块和个人信息维护模块。用户登录模块:用户通过输入注册的的账号和密码,然后进行身份验证,匹配成功 后实现登录功能。用户注册模块:用户输入合法的账号和密码可以实现注册功能。 查看客房信息模块:用户可以通过首页查看客房的价格,图片,详情等信息,从而   可以选择想要预定的房间。 客房预定模块:用户选择自己想要预定的客房后,可以通过输入相关信息进行订房操作。用户留言模块:用户可以向管理员发送留言。 充值模块:用户可以通过添加银行卡再为自己进行充值操作。 个人信息维护模块:用户可以修改自己的姓名、密码、身份证号等信息,还可以查看自己的订单。3.2.2  管理员模块功能分析对于管理员而言,一个好的管理系统总是能让酒店的管理工作事半功倍[7]。管理员 能够通过这个系统对自己的酒店情况一目了然,应该包括客户留言模块、客房管理模 块、订房信息管理模块、入住信息管理模块、统计分析模块、酒店新闻管理模块、会 员信息管理模块、员工信息管理模块、系统用户管理模块、个人信息维护模块。客户留言模块:管理员可以查看并回复用户的留言。客房管理模块:管理员可以管理客房信息,可以添加新的客房,删除已经停用的客房信息,还可以修改现有的客房信息。订房信息管理模块:管理员可以处理用户的订房请求,为用户办理入住手续。入住信息管理模块:对于没有注册的线下客户,也可以办理入住手续。统计分析模块:可以对酒店所有的入住信息进行记录和总结分析。酒店新闻管理模块:管理员可以更新网站上的新闻公告,展示图片等信息。会员信息管理模块:管理员可以查看到所有的注册会员信息,可以对会员信息进行删除,修改,添加操作。员工信息管理模块:管理员可以查看到自己公司所有的员工信息,而且还可以对员工的相关信息进行管理。系统用户管理模块:管理员可以查看到所有的系统管理员信息并对管理员信息进行管理。个人信息维护模块:管理员可以更改自己的登录密码或者是姓名、性别、手机号等 相关个人信息。​编辑 环境需要1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本;6.是否Maven项目:否;技术栈1. 后端:Spring+SpringMVC+Mybatis2. 前端:JSP+CSS+JavaScript+jQuery使用说明1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;4. 运行项目,在浏览器中输入http://localhost:8080/ 登录运行截图​编辑​编辑​编辑​编辑​编辑​编辑​编辑​编辑​编辑​编辑​编辑​编辑​编辑​编辑​编辑 用户管理控制层:package com.houserss.controller;import javax.servlet.http.HttpSession;import org.apache.commons.lang3.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.ResponseBody;import com.houserss.common.Const;import com.houserss.common.Const.Role;import com.houserss.common.ServerResponse;import com.houserss.pojo.User;import com.houserss.service.IUserService;import com.houserss.service.impl.UserServiceImpl;import com.houserss.util.MD5Util;import com.houserss.util.TimeUtils;import com.houserss.vo.DeleteHouseVo;import com.houserss.vo.PageInfoVo;/** * Created by admin */@Controller@RequestMapping(/user/)public class UserController if (ip != null && ip.length() > 0) String[] ips = ip.split(,);for (int i = 0; i  
将Apache的commons-fileupload.jar放在应用程序的WEB-INF\lib下,即可使用。下面举例介绍如何使用它的文件上传功能。 所使用的fileUpload版本为1.2,环境为Eclipse3.3+MyEclipse6.0。FileUpload 是基于 Commons IO的,所以在进入项目前先确定Commons IO的jar包(本文使用commons-io-1.3.2.jar)在WEB-INF\lib下。 此文作示例工程可在文章最后的附件中下载。 示例1 最简单的例子,通过ServletFileUpload静态类来解析Request,工厂类FileItemFactory会对mulipart类的表单中的所有字段进行处理,不只是file字段。getName()得到文件名,getString()得到表单数据内容,isFormField()可判断是否为普通的表单项。 demo1.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>File upload</title> </head> <body> //必须是multipart的表单数据。 <form name="myform" action="demo1.jsp" method="post" enctype="multipart/form-data"> Your name:
<input type="text" name="name" size="15"><br> File:
<input type="file" name="myfile"><br>
<input type="submit" name="submit" value="Commit"> </form> </body> </html> demo1.jsp <%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%> <%@ page import="org.apache.commons.fileupload.*"%> <%@ page import="org.apache.commons.fileupload.servlet.*"%> <%@ page import="org.apache.commons.fileupload.disk.*"%> <%@ page import="java.util.*"%> <% boolean isMultipart = ServletFileUpload.isMultipartContent(request);//检查输入请求是否为multipart表单数据。 if (isMultipart == true) { FileItemFactory factory = new DiskFileItemFactory();//为该请求创建一个DiskFileItemFactory对象,通过它来解析请求。执行解析后,所有的表单项目都保存在一个List中。 ServletFileUpload upload = new ServletFileUpload(factory); List items = upload.parseRequest(request); Iterator itr = items.iterator(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); //检查当前项目是普通表单项目还是上传文件。 if (item.isFormField()) {//如果是普通表单项目,显示表单内容。 String fieldName = item.getFieldName(); if (fieldName.equals("name")) //对应demo1.html中type="text" name="name" out.print("the field name is" + item.getString());//显示表单内容。 out.print("
"); } else {//如果是上传文件,显示文件名。 out.print("the upload file name is" + item.getName()); out.print("
"); } } } else { out.print("the enctype must be multipart/form-data"); } %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>File upload</title> </head> <body> </body> </html> 结果: the field name isjeff the upload file name isD:\C语言考试样题\作业题.rar 示例2 上传两个文件到指定的目录。 demo2.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>File upload</title> </head> <body> <form name="myform" action="demo2.jsp" method="post" enctype="multipart/form-data"> File1:
<input type="file" name="myfile"><br> File2:
<input type="file" name="myfile"><br>
<input type="submit" name="submit" value="Commit"> </form> </body> </html> demo2.jsp <%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%> <%@ page import="org.apache.commons.fileupload.*"%> <%@ page import="org.apache.commons.fileupload.servlet.*"%> <%@ page import="org.apache.commons.fileupload.disk.*"%> <%@ page import="java.util.*"%> <%@ page import="java.io.*"%> <%String uploadPath="D:\\\\temp"; boolean isMultipart = ServletFileUpload.isMultipartContent(request); if(isMultipart==true){ try{ FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List items = upload.parseRequest(request);//得到所有的文件 Iterator itr = items.iterator(); while(itr.hasNext()){//依次处理每个文件 FileItem item=(FileItem)itr.next(); String fileName=item.getName();//获得文件名,包括路径 if(fileName!=null){ File fullFile=new File(item.getName()); File savedFile=new File(uploadPath,fullFile.getName()); item.write(savedFile); } } out.print("upload succeed"); } catch(Exception e){ e.printStackTrace(); } } else{ out.println("the enctype must be multipart/form-data"); } %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>File upload</title> </head> <body> </body> </html> 结果: upload succeed 此时,在"D:\temp"下可以看到你上传的两个文件。 示例3 上传一个文件到指定的目录,并限定文件大小。 demo3.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>File upload</title> </head> <body> <form name="myform" action="demo3.jsp" method="post" enctype="multipart/form-data"> File:
<input type="file" name="myfile"><br>
<input type="submit" name="submit" value="Commit"> </form> </body> </html> demo3.jsp <%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%> <%@ page import="org.apache.commons.fileupload.*"%> <%@ page import="org.apache.commons.fileupload.servlet.*"%> <%@ page import="org.apache.commons.fileupload.disk.*"%> <%@ page import="java.util.*"%> <%@ page import="java.io.*"%> <% File uploadPath = new File("D:\\temp");//上传文件目录 if (!uploadPath.exists()) { uploadPath.mkdirs(); } // 临时文件目录 File tempPathFile = new File("d:\\temp\\buffer\\"); if (!tempPathFile.exists()) { tempPathFile.mkdirs(); } try { // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // Set factory constraints factory.setSizeThreshold(4096); // 设置缓冲区大小,这里是4kb factory.setRepository(tempPathFile);//设置缓冲区目录 // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Set overall request size constraint upload.setSizeMax(4194304); // 设置最大文件尺寸,这里是4MB List items = upload.parseRequest(request);//得到所有的文件 Iterator i = items.iterator(); while (i.hasNext()) { FileItem fi = (FileItem) i.next(); String fileName = fi.getName(); if (fileName != null) { File fullFile = new File(fi.getName()); File savedFile = new File(uploadPath, fullFile .getName()); fi.write(savedFile); } } out.print("upload succeed"); } catch (Exception e) { e.printStackTrace(); } %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>File upload</title> </head> <body> </body> </html> 示例4 利用Servlet来实现文件上传。 Upload.java package com.zj.sample; import java.io.File; import java.io.IOException; import java.util.Iterator; 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; @SuppressWarnings("serial") public class Upload extends HttpServlet { private String uploadPath = "D:\\temp"; // 上传文件的目录 private String tempPath = "d:\\temp\\buffer\\"; // 临时文件目录 File tempPathFile; @SuppressWarnings("unchecked") public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // Set factory constraints factory.setSizeThreshold(4096); // 设置缓冲区大小,这里是4kb factory.setRepository(tempPathFile);// 设置缓冲区目录 // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Set overall request size constraint upload.setSizeMax(4194304); // 设置最大文件尺寸,这里是4MB List items = upload.parseRequest(request);// 得到所有的文件 Iterator i = items.iterator(); while (i.hasNext()) { FileItem fi = (FileItem) i.next(); String fileName = fi.getName(); if (fileName != null) { File fullFile = new File(fi.getName()); File savedFile = new File(uploadPath, fullFile.getName()); fi.write(savedFile); } } System.out.print("upload succeed"); } catch (Exception e) { // 可以跳转出错页面 e.printStackTrace(); } } public void init() throws ServletException { File uploadFile = new File(uploadPath); if (!uploadFile.exists()) { uploadFile.mkdirs(); } File tempPathFile = new File(tempPath); if (!tempPathFile.exists()) { tempPathFile.mkdirs(); } } } demo4.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>File upload</title> </head> <body> // action="fileupload"对应web.xml中<servlet-mapping>中的设置. <form name="myform" action="fileupload" method="post" enctype="multipart/form-data"> File:
<input type="file" name="myfile"><br>
<input type="submit" name="submit" value="Commit"> </form> </body> </html> web.xml <servlet> <servlet-name>Uploadservlet-name> <servlet-class>com.zj.sample.Uploadservlet-class> servlet> <servlet-mapping> <servlet-name>Uploadservlet-name> /fileupload servlet-mapping>

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧