Struts2实现文件上传(四)

Struts2实现文件上传

配置文件struts.xml

<!--
/*
 * $Id: struts.xml 1364077 2012-07-21 12:57:02Z lukaszlenart $
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
-->
<!DOCTYPE struts PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
          "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
   <constant name="struts.custom.i18n.resources" value="message"></constant>
	<constant name="struts.multipart.saveDir" value="D:\MyEclipse\workspace\UploadFile\WebRoot\"></constant>
	<package name="struts2" extends="jfreechart-default">
		<action name="fileUpload" class="com.you.file.upload.action.FileUploadAction">
			<result name="success">/result.jsp</result>
			<result name="input">/file.jsp</result>
			<interceptor-ref name="fileUpload">
				<param name="maximumSize">409600</param>
				<param name="allowedTypes">application/vnd.ms-powerpoint</param>
			</interceptor-ref>
			<interceptor-ref name="defaultStack"></interceptor-ref>
		</action>
	</package>
</struts>

Struts2实现文件上传(四)

时间: 2024-08-08 15:58:36

Struts2实现文件上传(四)的相关文章

Struts2实现文件上传报错(四)

1.具体错误如下 2014-5-2 21:38:29 com.opensymphony.xwork2.util.logging.jdk.JdkLogger error 严重: Exception occurred during processing request: null java.lang.NullPointerException at com.you.file.upload.action.FileUploadAction.execute(FileUploadAction.java:56)

Struts2单文件上传原理及示例

一.文件上传的原理 表单元素的enctype属性指定的是表单数据的编码方式,该属性有3个值: 1.application/x-www-form-urlencoded:这是默认编码方式,它只处理表单域里的value属性值,采用这种编码方式的表单会将表单域的值处理成URL编码方式. 2.multipart/form-data:这种编码方式的表单会以二进制流的方式来处理表单数据,这种编码方式会把文件域指定文件的内容也封装到请求参数里. 3.text/plain:这种方式主要适用于直接通过表单发送邮件的

关于Struts2单文件上传

要实现Struts2框架的文件上传,需要用到2个jar包 commons-fileupload-1.2.2.jar commons-io-2.0.1.jar 由于文件解析Struts2内部已经帮我们做好了,大大降低了开发难度,我们只需要在Action里设置好对应的参数,目录进行使用即可. 来个小示例: upload.jsp 这个页面的表单有三点需要注意的: 1.表单必须使用post方式提交 2.表单编码类型 enctype="multipart/form-data"   3.<s

struts2的文件上传

struts2的文件上传,布布扣,bubuko.com

Struts2实现文件上传报错(一)

1.具体报错如下 2014-5-1 23:02:38 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [jsp] in context with path [/UploadFile] threw exception [An exception occurred processing JSP page /file.jsp at line 28 25: <table> 26

Struts2实现文件上传报错(二)

编译Lua时,出现这样的错误: gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lua.o lua.clua.c:67:31: error: 查阅了一下,centOS上需要安装readline-devel ncurses-devel yum install readline-devel ncurses-devel 测试平台成功. [[email protected] lua-5.2.3]# make linux test cd src &

Struts2实现文件上传报错(三)

1.具体错误如下 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2014-5-1 23:17:23 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.27 usin

Struts2实现文件上传(一)

Struts2实现文件上传 文件上传页面 file.jsp: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ taglib prefix="s" uri="/struts-tags" %> <% String path = request.getContextPath(); Str

Struts2实现文件上传(二)

Struts2实现文件上传 文件上传页面 file.jsp: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ taglib prefix="s" uri="/struts-tags" %> <% String path = request.getContextPath(); Str