鎶婂唴瀹瑰啓濡傛枃浠剁殑鍏ラ棬绾ч棶棰?/a>

时间:2023-02-12 00:29:03
<%@ page contentType="text/html; charset=gb2312" import="java.io.*" buffer="64kb"%>
<html> 
<body>
<% 
request.setCharacterEncoding("gb2312");
String content=request.getParameter("content");
%>
<%
try
{
PrintWriter writer= new PrintWriter(new BufferedWriter(new FileWriter("C:\\Tomcat\\webapps\\jsp\\test\\test.txt",true)));
writer.write(content);
writer.close();
out.println("宸茬粡鎶婂唴瀹瑰啓鍏ュ埌 C:\Tomcat\webapps\jsp\test\test.txt"); 
}
catch(Exception e)
{
  out.println(e);
  e.printStackTrace();
}
%>

<form action="writeFile.jsp" method=post>
<textarea name=content cols=20 rows=5></textarea><br>
<input type=submit value=鎻愪氦>
</form>
</body>
</html>
=============================
閿欒鎻愮ず锛?
HTTP Status 500 - 

type Exception report

message 

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

exception 

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 8 in the jsp file: /writeFile.jsp
Invalid escape sequence (valid ones are  \b  \t  \n  \f  \r  \"  \'  \\ )
5: request.setCharacterEncoding("gb2312");
6: String content=request.getParameter("content");
7: %>
8: <%
9: try
10: {
11:  PrintWriter writer= new PrintWriter(new BufferedWriter(new FileWriter("C:\\Tomcat\\webapps\\jsp\\test\\test.txt",true)));


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


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

======================================
璇烽珮鎵嬫寚鏁欏晩~

8 涓В鍐虫柟妗?/h2>

#1


浣犺矾寰勬湁闂锛孿t鏄浆绉诲瓧绗?浣犵洰褰曟敼涓€涓嬪氨鍙互,姣斿璇碿:\\test,鎴栬€卌:\abc.鍓嶉潰2涓猏\,鍚庨潰1鏍筡.

#2


鐢ㄨ繖涓被鍚ileOutputStream

#3


璇ュ洖澶嶈鐗堜富鍒犻櫎

#4


sssky,璋㈣阿浣犵殑绛斿锛屼絾鏄繕鏄笉琛岋紝杩樻槸鍑虹幇鍚屾牱鐨勯敊璇彁绀恒€傘€傘€傝€屼笖鎴戜釜浜鸿涓轰綘璇寸殑c:\abc鏄笉鏄篃搴旇鏄痗:\\abc鍛€

gongyali2005锛屼篃璋㈣阿浣犲洖澶嶏紝浣嗕篃杩樻槸涓嶈锛岄敊璇彁绀轰篃鍩烘湰娌″彉銆傘€傘€?

#5


PrintWriter writer= new PrintWriter(new BufferedWriter(new FileWriter("C:\\Tomcat\\webapps\\jsp\\test\\test.txt",true)));
writer.write(content);
writer.close();
out.println("宸茬粡鎶婂唴瀹瑰啓鍏ュ埌 C:\\Tomcat\\webapps\\jsp\\test\\test.txt"); 
濡傛灉浣犵殑杩欎釜鏂囦欢澶癸紙C:\\Tomcat\\webapps\\jsp\\test\\锛夊瓨鍦紝浠g爜搴旇娌℃湁闂锛庢垜鐓т綘杩欎箞鍐欑殑锛屽彲浠ュ疄鐜板姛鑳?

#6


C:\Tomcat\webapps\jsp\test\test.txt杩欎釜鏂囦欢纭畾瀛樺湪鍚?

#7


C:\Tomcat\webapps\jsp\test\test.txt杩欎釜鏂囦欢纭疄瀛樺湪锛屾€庝箞浼氳繖鏍峰晩锛屼綘閭e彲浠ワ紝鎴戣繖鎬庝箞灏变笉琛屽憿锛燂紒

#8


File newFile = new File("f:\\new.txt");
FileWriter fw = new FileWriter(newFile);
BufferedWriter bw = new BufferedWriter(fw);
bw.write("hello world!\r\nA\r\nB");
bw.flush();
bw.close();

#9


浣犲厛涓嶈鐢ㄥ甫缂撳瓨鐨勭被.

#1


浣犺矾寰勬湁闂锛孿t鏄浆绉诲瓧绗?浣犵洰褰曟敼涓€涓嬪氨鍙互,姣斿璇碿:\\test,鎴栬€卌:\abc.鍓嶉潰2涓猏\,鍚庨潰1鏍筡.

#2


鐢ㄨ繖涓被鍚ileOutputStream

#3


璇ュ洖澶嶈鐗堜富鍒犻櫎

#4


sssky,璋㈣阿浣犵殑绛斿锛屼絾鏄繕鏄笉琛岋紝杩樻槸鍑虹幇鍚屾牱鐨勯敊璇彁绀恒€傘€傘€傝€屼笖鎴戜釜浜鸿涓轰綘璇寸殑c:\abc鏄笉鏄篃搴旇鏄痗:\\abc鍛€

gongyali2005锛屼篃璋㈣阿浣犲洖澶嶏紝浣嗕篃杩樻槸涓嶈锛岄敊璇彁绀轰篃鍩烘湰娌″彉銆傘€傘€?

#5


PrintWriter writer= new PrintWriter(new BufferedWriter(new FileWriter("C:\\Tomcat\\webapps\\jsp\\test\\test.txt",true)));
writer.write(content);
writer.close();
out.println("宸茬粡鎶婂唴瀹瑰啓鍏ュ埌 C:\\Tomcat\\webapps\\jsp\\test\\test.txt"); 
濡傛灉浣犵殑杩欎釜鏂囦欢澶癸紙C:\\Tomcat\\webapps\\jsp\\test\\锛夊瓨鍦紝浠g爜搴旇娌℃湁闂锛庢垜鐓т綘杩欎箞鍐欑殑锛屽彲浠ュ疄鐜板姛鑳?

#6


C:\Tomcat\webapps\jsp\test\test.txt杩欎釜鏂囦欢纭畾瀛樺湪鍚?

#7


C:\Tomcat\webapps\jsp\test\test.txt杩欎釜鏂囦欢纭疄瀛樺湪锛屾€庝箞浼氳繖鏍峰晩锛屼綘閭e彲浠ワ紝鎴戣繖鎬庝箞灏变笉琛屽憿锛燂紒

#8


File newFile = new File("f:\\new.txt");
FileWriter fw = new FileWriter(newFile);
BufferedWriter bw = new BufferedWriter(fw);
bw.write("hello world!\r\nA\r\nB");
bw.flush();
bw.close();

#9


浣犲厛涓嶈鐢ㄥ甫缂撳瓨鐨勭被.