The method getRealPath(String) from the type ServletRequest is deprecated

2024-04-30 03:58

本文主要是介绍The method getRealPath(String) from the type ServletRequest is deprecated,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

File tempFile = new File(fileName);// 构造临时对象
      // String savePath=tempFile.getName();
      // //返回上传文件在客户端的完整路径名称
      // request.setAttribute("filename", savePath);

//File file = new File(request.getRealPath("/upload"), //此句报错。
      File file = new File(request.getSession().getServletContext().getRealPath("/upload"),//改成这句。就Ok咯
        tempFile.getName()); // 获取根目录对应的真实物理路径

这篇关于The method getRealPath(String) from the type ServletRequest is deprecated的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/947851

相关文章

ITMS-90339: Deprecated Info.plist Key

The Info.plist contains a key 'UIApplicationExitsOnSuspend' in bundle 在info.plist中找到这个key——UIApplicationExitsOnSuspend,然后删掉就可以了。确保没问题的话也跑一下看是否可以能在后台运行。 需要先转换一下,才能找到对应的key

BD错误集锦7——在集成Spring MVC + MyBtis时使用c3p0作为数据库时报错Method com/mchange/v2/c3p0/impl/NewProxyPreparedStatem

异常信息如下: Type Exception ReportMessage Handler dispatch failed; nested exception is java.lang.AbstractMethodError: Method com/mchange/v2/c3p0/impl/NewProxyPreparedStatement.isClosed()Z is abstractDescr

1_CString char* string之间的关系

CString转char*,string string转char*,CString char* 转CString,string 一、CString转char*,string //字串转换测试 CString CString1; std::string string1; CHAR* char1=NULL; //1string1=CString1.GetBuffer();CStri

query string parameters 和request payload

HTTP请求中,如果是get请求,那么表单参数以name=value&name1=value1的形式附到url的后; post请求:表单参数是在请求体中,也是name=value&name1=value1的形式在请求。 export const voucherDetailAdd=(token,formStr) =>{return axios.post(`${base}/voucher/deta

【Java】ArrayListString转化为String数组问题

Java的容器类Collections中toArray()方法,可以把诸如ArrayList<String>的动态数组、不定长转化静态数组、定长数组String[] 但是,如下的转化方式是错误的。 [java]  view plain copy String[] strArray = (String[]) arrayList.toArray();   如果这样执行会导致

C++:字符串string类使用

C++字符串和C字符串的对比 (1)C语言严格说没有字符串的概念,C字符串其实就是字符数组或字符指针 (2)C++和之后的java等都有字符串,本质是一个class (3)C++字符串的优势是标准库自带可用于字符串的各种处理算法和方法 (4)C++实际开发中建议使用C++字符串而不是沿用C式字符串 字符串string类使用 std::string str = "Hello, Worl

Java中String和StringBuffer的区别?

String 不是简单类型,而是一个类,它被用来表示字符序列。字符本身符合 Unicode 标准,其初始化方式有两种。如:String greeting=“Good Morning! \n”;String greeting=new String(=“Good Morning! \n”);String的特点是一旦赋值,便不能更改其指向的字符对象,如果更改,则会指向一个新的字符对象 。StringB

C++系列-String(二)

🌈个人主页:羽晨同学  💫个人格言:“成为自己未来的主人~”   #define _CRT_SECURE_NO_WARNINGS#include<string>#include<iostream>#include<list>#include<algorithm>using namespace std;void test_string3(){string s1("hel

「Debug R」报错unable to find an inherited method for function是如何产生的

在一个群里看到这样一条报错,截图如下: 报错信息 当然这种问题解决起来也很快,无非就是把报错信息复制出来放在搜索引擎上,只不过你要挑选合适的搜索引擎。 百度 谷歌 必应 解决方案就是用dplyr::select。 虽然报错解决了,但是我还想着要重复出这个报错。因为只有能重复出报错,才能证明你不是运气好才解

【Java反射】getDeclaredField(String name) 和 getField(String name)区别

getDeclaredField(String name) 和 getField(String name) 都是Java反射API中用于获取类字段(成员变量)的方法,但它们之间存在一些关键的区别: getDeclaredField(String name) 功能:这个方法返回的是声明在该类中的指定名称的字段,包括私有、受保护、默认(包访问权限)和公有字段,不论该字段是在哪个类中声明的。也就是说