惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
A
Arctic Wolf
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
S
Schneier on Security
The Cloudflare Blog
Security Latest
Security Latest
S
SegmentFault 最新的问题
L
Lohrmann on Cybersecurity
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cyber Attacks, Cyber Crime and Cyber Security
K
Kaspersky official blog
Latest news
Latest news
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
F
Fortinet All Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
美团技术团队
博客园 - 叶小钗
H
Help Net Security
博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
A
About on SuperTechFans
WordPress大学
WordPress大学
Cloudbric
Cloudbric
IT之家
IT之家
Last Week in AI
Last Week in AI
S
Securelist
Google Online Security Blog
Google Online Security Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
L
LINUX DO - 最新话题
Know Your Adversary
Know Your Adversary
爱范儿
爱范儿
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
Google Developers Blog
C
CERT Recently Published Vulnerability Notes
宝玉的分享
宝玉的分享
博客园 - Franky
TaoSecurity Blog
TaoSecurity Blog
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
B
Blog

博客园 - steeven

Dlink dwl-122 ver c1在windows 2003下的驱动安装 利用工作流给Windows SharePoint Service 3.0添加Skype通知功能 windows sharepoint service 3.0 wss3 URL 映射问题,差点把网站废掉 替朋友发布一下:招聘java开发人员 YY一下IT业的未来 c盘不够用了怎么办?目录连接,简单扩充 wpf中显示HTML - steeven - 博客园 编程查看对象的xaml c#语法里面应该加上对属性的reflection引用 WPF应用程序模型 wpf印象 wpf 3d笔记1 wpf的一些小demo (links) wpf的3d遗憾 WPF写的Guess Number 比较简洁的Singleton Proces(唯一进程)程序 Windows维修 在虚拟机下体验ubuntu(有奔头) C#版的2006新春祝福 - steeven - 博客园
vs2005 Click Once程序在Jsp虚拟主机上发布,不能安装问题
steeven · 2006-01-12 · via 博客园 - steeven

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

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

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class MapMime4Application extends HttpServlet {
    
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path 
= request.getServletPath();
        path 
= this.getServletContext().getRealPath(path);
        File file 
= new File(path);
        
if (!file.exists()){
            response.setStatus(
404);
            
return;
        }

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

        }
        
    }

}

修改web.xml, 增加:

   <servlet>
      
<servlet-name>MapMime4Application</servlet-name>
      
<servlet-class>MapMime4Application</servlet-class>
    
</servlet>
  
<servlet-mapping>

    
<servlet-name>MapMime4Application</servlet-name>
    
<url-pattern>*.application</url-pattern>
  
</servlet-mapping>

修改后ClickOnce可以正常安装执行 :)