Struts 2 问题
各路大神,我在用struts 2 写上传文件时,老是报错。但是,我不知道怎么修改。
下面是服务器提示的错误
No result defined for action action.Upload and result success
description The requested resource (No result defined for action action.Upload and result success) is not available
下面是struts-xml代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="main" extends="struts-default">
<action name="loginPerson"
class="action.Login">
<result name="login">/Login.jsp</result>
<result name="success">/Success.jsp</result>
</action>
<action name="upload"
class="action.Upload">
<result name="input">/Success.jsp</result>
<result name="success">/Upsuccess.jsp</result>
<interceptor-ref name="fileUpload">
<param name="allowedTypes">application/msword</param>
</interceptor-ref>
</action>
</package>
</struts>
下面是/Success.jsp 的代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags" prefix="struts"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'Success.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<struts:actionerror/>
<struts:form action="upload" enctype="multipart/form-data" method="post">
<struts:label value="上传文件"></struts:label>
<struts:file name="picture" label="文件"></struts:file>
<struts:submit value="开始上传" method="upload"></struts:submit>
</struts:form>
</body>
</html>
下面是Upload 的代码
package action;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class Upload extends ActionSupport
{
private File picture;
private String pictureContentType;
private String pictureFileName;
public String execute()
{
return "input";
}
&