关天response.setContentType()和application/json
2011-07-22 17:36
477 查看
response.setContentType()的作用是使客户端浏览器,区分不同种类的数据,并根据不同的MIME调用浏览器内不同的程序嵌入模块来处理相应的数据。例如web浏览器就是通过MIME类型来判断文件是GIF图片。通过MIME类型来处理json字符串。
Tomcat的安装目录\conf\web.xml 中就定义了大量MIME类型 ,你可也去看一下。
做用表单上传文件,想在服务端验证上传文件的类型,只允许上传GIF,JPG,ZIP, 我们有两种方法:
第一:检查文件的扩展名;
第二:检查文件的MIME类型 。
检查文件的扩展名的方法,很简单快捷, 但是 a.jsp 改名为 a.jpg能可以绕过检查上传了。
application/json
http://stackoverflow.com/questions/477816/the-right-json-content-type
Tomcat的安装目录\conf\web.xml 中就定义了大量MIME类型 ,你可也去看一下。
做用表单上传文件,想在服务端验证上传文件的类型,只允许上传GIF,JPG,ZIP, 我们有两种方法:
第一:检查文件的扩展名;
第二:检查文件的MIME类型 。
检查文件的扩展名的方法,很简单快捷, 但是 a.jsp 改名为 a.jpg能可以绕过检查上传了。
application/json
http://stackoverflow.com/questions/477816/the-right-json-content-type
相关文章推荐
- 关天response.setContentType()
- The content type application/json of the response message does not match the content type of the binding (application/soap+xml;
- 设置后台传送json的response.setContentType()格式
- 传送json的response.setContentType()格式
- response.setContentType()的作用及参数
- response.setContentType()的作用及参数
- response.setContentType()的作用及参数
- Content type expected:<application/json;charset=UTF-8> but was:<application/hal+json;charset=UTF-8>
- Response.setContentType()详细参数
- response.setContentType()的参数 你知道多少
- 使用HttpServletResponse.setContentType();解决输出文件流乱码
- response.setContentType() 详解
- response.setContentType()的使用
- response.setContentType()的作用及参数
- response.setContentType("text/html;charset=utf-8")后依然乱码的解决方法
- response.setContentType()的作用及参数
- response.setContentType()的作用及参数
- response.setContentType()的作用及参数
- response.setContentType和response.setCharacterEncoding区别
- response.setContentType()的作用及参数