1. 主页 > vs安装问题 > VS2005安装问题 >

vs2005 Click Once程序在Jsp虚拟主机上发布,不能安装

发布之后点击运行按钮,看到的是.application文件的xml内容,查阅msdn后发现.application文件应该定义mime类型为:application/x-ms-application

因为主机是虚拟主机,不具备修改mime映射的权限,因此自己写servlet,映射到*.application文件。

None.gifimport java.io.File;
None.gif
import java.io.FileInputStream;
None.gif
import java.io.IOException;
None.gif
None.gif
import javax.servlet.ServletException;
None.gif
import javax.servlet.http.HttpServlet;
None.gif
import javax.servlet.http.HttpServletRequest;
None.gif
import javax.servlet.http.HttpServletResponse;
None.gif
None.gif
ExpandedBlockStart.gifContractedBlock.gif
public class MapMime4Application extends HttpServlet dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif    
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException dot.gif{
InBlock.gif        String path 
= request.getServletPath();
InBlock.gif        path 
= this.getServletContext().getRealPath(path);
InBlock.gif        File file 
= new File(path);
ExpandedSubBlockStart.gifContractedSubBlock.gif        
if (!file.exists())dot.gif{
InBlock.gif            response.setStatus(
404);
InBlock.gif            
return;
ExpandedSubBlockEnd.gif        }

InBlock.gif        response.setContentType(
"application/x-ms-application");
InBlock.gif        FileInputStream stream 
= null;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
try dot.gif{
InBlock.gif            stream 
= new FileInputStream(file);
InBlock.gif            
byte[] buf = new byte[(int) file.length()];
InBlock.gif            stream.read(buf);
InBlock.gif            response.getOutputStream().write(buf);
ExpandedSubBlockStart.gifContractedSubBlock.gif        }
 finallydot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
if(stream != nulldot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif                
try dot.gif{
InBlock.gif                    stream.close();
ExpandedSubBlockStart.gifContractedSubBlock.gif                }
 catch (Exception e) dot.gif{
ExpandedSubBlockEnd.gif                }
                
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }
        
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

修改web.xml, 增加:
None.gif   <servlet>
None.gif      
<servlet-name>MapMime4Application</servlet-name>
None.gif      
<servlet-class>MapMime4Application</servlet-class>
None.gif    
</servlet>
None.gif  
<servlet-mapping>
None.gif
None.gif    
<servlet-name>MapMime4Application</servlet-name>
None.gif    
<url-pattern>*.application</url-pattern>
None.gif  
</servlet-mapping>
修改后ClickOnce可以正常安装执行 :)

本文由VS软件圈(vssoft.net)发布,不代表VS软件圈立场,转载联系作者并注明出处:https://vssoft.net/vsazwt/VS2005anzhuangwenti/2020/0721/733.html

联系我们

在线咨询:点击这里给我发消息

微信号:PREEE8

工作日:9:30-18:30,节假日休息