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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - steeven

Dlink dwl-122 ver c1在windows 2003下的驱动安装 利用工作流给Windows SharePoint Service 3.0添加Skype通知功能 - steeven 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) - steeven 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可以正常安装执行 :)