taglib-html:浏览器会自动解析

引用:

<%@  taglib uri="http://jakarta.apache.org/struts/tags-html" profix="html"%>

jsp页面使用

File

<html:file>生成一个<input type=file>元素来支持文件上传
	Jsp页面,必须是enctype="multipart/form-data",一个字都不能差
		<html:form action="HtmlFile.do" enctype="multipart/form-data">
			File:<html:file property="file"/>
		</html:form>
		
	Formbean里面Form类添加属性
		private FormFile file;
		
	eg:
	FormFile file=uploadForm.getFile();
	InputStream in=file.getInputStream();
	String fileName=file.getFileName();
	int size=file.getFileSize();
	//得到真实路径
	String path=super.servlet.getServletContext().getRealPath("/upload");
	OutputStream out=new FileOutputStream(path+"\"+fileName);
	byte[] buf=new byte[size];
	in.read(buf);
	out.write(buf);
	in.close();
	out.close();


解决验证信息中的中文乱码问题

创建build.xml文件
	调用native2ascii.exe进行转码
	代码:
	<project>
		<target name="i18n">
			<native2ascii dest="com/amaker/struts" src="com/amaker/struts/temp" encoding="UTF-8" includes="ApplicationResources*.properties"/>
		</target>
	</project>



经验分享 程序员 微信小程序 职场和发展