未找到HttpServletRequest getPart(") [英] HttpServletRequest getPart(") not found

查看:1062
本文介绍了未找到HttpServletRequest getPart(")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么它不起作用。
我试图接受我的servlet中的multipart-formdata,但是没有显示 request.getPart()。我正在使用glassfish 3.1.2服务器。使用的Tha框架是用于开发应用程序的vaadin。任何人都可以帮我解决这个问题吗?

解决方案

getPart()方法在自动完成时,那么这只能意味着该项目没有被配置为一个Servlet 3.0兼容项目。 该方法是在Servlet 3.0中引入的。



你没有告诉任何你正在使用哪个IDE,你的问题历史没有提供任何线索因此,让我们假设它是相当广泛使用的Eclipse。在这种情况下,如果您已在项目属性中将 Dynamic Web Project 与Servlet 3.0兼容容器正确关联为目标运行时,则需要在2个位置进行配置(否则 HttpServletRequest 和配置根本不会编译):


  1. 在项目属性的 Project Facets 部分中, Dynamic Web Module 版本必须设置为3.0。







  2. 如果您的IDE生成了 /WEB-INF/web.xml 文件,那么你需要确保它的< web-app> 根声明符合Servlet 3.0,否则它在运行时仍然会失败。 b
    $ b

     <?xml version =1.0encoding =UTF-8?> 
    < web-app
    xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
    xmlns =http://java.sun.com / xml / ns / javaee
    xsi:schemaLocation =http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0 .xsd
    version =3.0>

    < / web-app>



I don't know why it is not working. I am trying to accept multipart-formdata in my servlet but request.getPart("") is not showing. I am using glassfish 3.1.2 server. Tha framework used is vaadin for developing application. Can any one help me to fix this problem?

解决方案

Assuming that your concrete problem is indeed that your IDE didn't show the getPart() method on autocomplete, then that can only mean that the project is not configured as a Servlet 3.0 compatible project. That method was namely introduced in Servlet 3.0.

You didn't tell anything about which IDE exactly you're using and your question history doesn't give any clues as well, so let's assume that it's Eclipse which is rather widely used. In that case, you need to configure it at 2 places, provided that you've correctly associated the Dynamic Web Project with a Servlet 3.0 compatible container as Targeted Runtimes in project's properties (otherwise HttpServletRequest and consorts wouldn't have compiled at all):

  1. In the Project Facets section of project's properties, the Dynamic Web Module version must be set to 3.0.


  2. If your IDE has generated a /WEB-INF/web.xml file, then you need to make sure that its <web-app> root declaration also matches Servlet 3.0, otherwise it would still fail during runtime.

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        version="3.0">
    
    </web-app>
    

这篇关于未找到HttpServletRequest getPart(&quot;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆