Ver Mensaje Individual
  #8 (permalink)  
Antiguo 24/11/2011, 18:23
abulon81
 
Fecha de Ingreso: mayo-2010
Mensajes: 99
Antigüedad: 14 años
Puntos: 5
Respuesta: El recurso requerido.

por ejemplo yo tengo en mi struts , por que lo tuyo es spring ya vi:
algo asi

esto esta en un action

Código PHP:
    public ActionForward subirArchivo(ActionMapping mapping,ActionForm form,
                                      
HttpServletRequest request,HttpServletResponse response ){
         
String forwar null;
         
FileForm fileForm = (FileFormform;
         
FormFile document fileForm.getUploadFile();
         
String nomFile document.getFileName();
         
FileOutputStream outputStream null;
         
String path null;
         
int size 0;
         
TestForm forma null;
          if (
request.getSession().getAttribute("user")==null){
              return 
mapping.findForward("error");
          }
            try{
                 
                 
HttpSession session request.getSession() ;
                 
ServletContext context session.getServletContext();
                 
path context.getRealPath("/archivosCargados/");
                 
size document.getFileSize(); 

                 
File folder = new File(path);
                 if(!
folder.exists()) {
                     
folder.mkdir();
                 }
                 
                 
DataInputStream in = new DataInputStream(document.getInputStream());
                 
byte dataBytes [] = new byte[size];
                 
int byteRead 0;
                 
int totalBytesRead 0;
                 while(
totalBytesRead<size) {
                     
byteRead in.read(dataBytestotalBytesReadsize);
                     
totalBytesRead += byteRead
                 }
                
String saveFile path nomFile;
                
outputStream = new FileOutputStream(saveFile);
                
outputStream.write(dataBytes0size-1);
                
outputStream.flush();
                
outputStream.close();
                
System.out.println("Server path:" +path);
               
                 
forwar "upload";
            }
            catch(
Exception e){
             
e.printStackTrace();
             
forwar "error";
            }
            
finally {
             return 
mapping.findForward(forwar);
            }
                                      
     } 
en el jsp viene algo asi:

Código PHP:
<%@ page contentType="text/html;charsetutf-8"%>
<%@ 
taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ 
taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ 
taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<
html>
  <
head>
    <
meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    
    <
script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/TestAjax.js'></script>                                    
    <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
    <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script> 
    <script type='text/javascript'> 
        function hello()
        {
            var name=DWRUtil.getValue("message");
            TestAjax.sayHello(name,function(data){
            DWRUtil.setValue("result",data);         
          });
        }
    
    </script>  
  
<script type="text/javascript" >  

jQuery(document).ready(function(){  
            
       jQuery('a[name=subirArchivo]').click(
          function ()
            {
            alert('aki subir');
            jQuery('#forma').attr("action",'<%=request.getContextPath()%>/muestra.do?showAct=subirArchivo');
            jQuery('#forma').submit();
            });
       
       
    
    });    
</script>    
    
<style type="text/css">

</style>
    <title>test</title>
  </head>
  <body>
  <%  
//    response.setHeader("Cache-Control", "no-cache");
//    response.setHeader("Pragma", "no-cache");
//    response.setHeader("Expires", "Thu, 29 Oct 2000 17:04:19 GMT");
//    response.setContentType("text/html; charset=utf-8");
%>
<html:form action="/muestra.do" styleId="forma" enctype="multipart/form-data">
 <table cellpadding="2" cellspacing="3">
     <tr>
         <td>
            <div>
                <input type="text" name="message" id="message">
                <input type="button" value="Say Hello" onclick="hello();">
                <span id="result">
                </span>
            </div>
        </td>
    </tr>
   
    <tr>
        <td width="25%">
           <html:file property="uploadFile" value="Seleccionar file" size="10" /><br>
        </td>
    </tr>
    <tr>
        <td width="25%">
            
                        <div class="right controles">
                                <a class="button3"  name="subirArchivo" ><bean:message key='boton.upload'/></a>
                                
                                <a  onclick="aprobarDocumentos()"; class="boton-rojo" name="AprobarSeleccionados" id="aprobar"><bean:message key='boton.upload'/></a>
                                <div class="clear"></div>
                    </div><br>
        </td>
    </tr>
    
    
    </table>
     
</html:form>
  </body>
</html> 
Cheers, Hope this helps ...Solo transfiere el archivo de un sitio a otro