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

推荐订阅源

G
Google Developers Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
IT之家
IT之家
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Threatpost
Cyberwarzone
Cyberwarzone
AWS News Blog
AWS News Blog
博客园 - 司徒正美
C
Cyber Attacks, Cyber Crime and Cyber Security
Latest news
Latest news
S
Secure Thoughts
S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
S
Security Affairs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hacker News: Ask HN
Hacker News: Ask HN
大猫的无限游戏
大猫的无限游戏
博客园_首页
S
Security @ Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
AI
AI
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
Project Zero
Project Zero
P
Proofpoint News Feed
T
Tor Project blog
P
Privacy International News Feed
阮一峰的网络日志
阮一峰的网络日志
博客园 - 聂微东
月光博客
月光博客
Forbes - Security
Forbes - Security
量子位
I
Intezer
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
腾讯CDC
N
Netflix TechBlog - Medium
www.infosecurity-magazine.com
www.infosecurity-magazine.com
L
Lohrmann on Cybersecurity
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - 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可以正常安装执行 :)