这是将判断文件是否存在放在一个单独的过程中,错误如下:
An error occurred at line: 7 in the jsp file: /service/upload-save.jsp
Syntax error on token "(", ; expected
7: <%public String CheckFiles(String cFile){
8: String iPath=request.getRealPath("upload\\download\\");
9: File iFile=new File(iPath,cFile);
10: return "Path:"+ iFile +"<hr>";}如果将这两行放在程序中间,则错误如下:
An error occurred at line: 29 in the jsp file: /service/upload-save.jsp
The type File is ambiguous
28: String iPath=request.getRealPath("upload\\download\\");
29: File iFile=new File(iPath,UpFile.getFileName());
30: return "Path:"+ iFile +"<hr>";
An error occurred at line: 7 in the jsp file: /service/upload-save.jsp
Syntax error on token "(", ; expected
7: <%public String CheckFiles(String cFile){
8: String iPath=request.getRealPath("upload\\download\\");
9: File iFile=new File(iPath,cFile);
10: return "Path:"+ iFile +"<hr>";}如果将这两行放在程序中间,则错误如下:
An error occurred at line: 29 in the jsp file: /service/upload-save.jsp
The type File is ambiguous
28: String iPath=request.getRealPath("upload\\download\\");
29: File iFile=new File(iPath,UpFile.getFileName());
30: return "Path:"+ iFile +"<hr>";
解决方案 »
- 在做分页的时候,出现java.lang.NumberFormatException: null 错误
- jsp连接mysql数据库查询,并在页面显示
- 关于Tiles框架在struts-config.xml中的设置跳转的问题
- js与Servlet之间如何传递大量数据?
- jsp中跨页面传数据问题,我就不相信没人会了!
- jfree.chart画图!
- 问个比较变态问题:能不能把java数组里的值传递给js的变量
- 一个JavaScript的简单问题
- 读出数条数据自动放表格,如何实现隔行变色
- 急!!!!lucene全文检索的问题?
- 如何让带日期联动的表单在第一次提交后日期不再初始化,后面显示所选择的时间
- 如上一个页面或者几个页面上,动态的显示表中的数据?谢谢了这个问题困扰很久了,帮帮忙!
和System.out.println("========UpFile==========="+UpFile.getFileName());
打印一下看看得到什么值
前面那个,是这样的:
<%
public String CheckFiles(String cFile){
String iPath=request.getRealPath("upload\\download\\");
File iFile=new File(iPath,cFile);
return "Path:"+ iFile +" <hr> ";
}
%>
Syntax error on token "(", ; expected 这个错误是差个括号。但我看几行代码,并不缺。
如果在页面中将这几行去掉,就没有错误。你用System.out.println("========iPath==========="+iPath);
和System.out.println("========UpFile==========="+UpFile.getFileName());
打印一下看看得到什么值等不到后面的显示,前面就已开始出错了。
其中UpFile.getFileName()是可以正常获取到值的。
即便我将31: File iFile=new File(iPath,UpFile.getFileName());改成:
31: File iFile=new File(iPath,"001.jpg");
也是一样的错,其中:001.jpg确实是完整路径:D:\Tomcat\webapps\ROOT\upload\download中的一个实际存在的文件。
如果在30行后out.print(iPath);,显示的路径就是D:\Tomcat\webapps\ROOT\upload\download\An error occurred at line: 31 in the jsp file: /service/upload-save.jsp
The type File is ambiguous
28: try{
29:
30: String iPath=request.getRealPath("upload\\download\\");
31: File iFile=new File(iPath,UpFile.getFileName());
32: out.print ("Path:"+ iFile +"<hr>");
33:
34: }catch(Exception e){}
改成File iFile=new File(iPath + UpFile.getFileName()); 试试