cmd 模拟 打开url:C:\Windows\System32\rundll32.exe url.dll, FileProtocolHandler http://tw.yahoo.com
<%@ page contentType="application/msexcel"%> <% // excel response.setHeader("Content-disposition", "attachment; filename=MyExcel.xls"); // ie excel //response.setHeader("Content-disposition","inline; filename=MyExcel.xls"); //Word contentType="application/msexcel" contentType="application/msword" %> <html> <head> <title>test Excel Word</title> </head> <body> <table width="500" border="1" align="center"> <thead> <tr> <th class="header">thead1</th> <th class="header">thead1</th> <th class="header">thead1</th> <th class="header">thead1</th> </tr> </thead> <tbody> <tr> <td width="7%">123</td> <td width="7%">213</td> <td width="18%">321</td> <td width="68%">332</td> </tr> <tr> <td>20061006</td> <td align="right">xxx</td> <td>xxx</td> <td>xxxxx</td> </tr> <tr> <td>20061007</td> <td>xx</td> <td>xxx</td> <td>xxxxx</td> </tr> <tr> <td>20061008</td> <td>xx</td> <td>xxx</td> <td>xxxxx</td> </tr> </tbody> </table> </body> </html>
estful web services,相信对于大多数读者来说已经不是什么新鲜的名词,网上能搜到的资料也是汗牛充栋,数不胜数,故在此本人就不再赘述,仅提供若干参考网站,同时附件中也提供一些收集到的restful web services的学习资料,有兴趣的朋友可以下载来看一下。在这里我只是想简单说一下如何利用eclipse和tomcat如何快速实现restful web services的HelloWorld。接着下来我想通过不断的学习由浅入深形成一系列的文章。
第一步:新建web项目
在eclipse中新建一个Web Project即可,地球上的java开发者都知道怎么做的
第二步:集成restful web services
把附件中的lib.zip解压后的所有jar复制到项目的lib目录下,然后在web.xml里增加如下代码:
<servlet>
<servlet-name>JerseyServlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JerseyServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
第三步:新建HelloWorld类
package net.jackshow.test;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/helloWorld")
public class HelloWorld {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String helloWorld(){
String ret = "Hello World!";
return ret;
}
}
完成后把项目发布到tomcat,然后在浏览器中输入http://hostname:port/projectname/services/helloWorld(注:这里的hostname是指你的主机名,如localhost;port是tomcat的端口,如8080;projectname是指你第一步新建的项目名),浏览器上即打印出“Hello World!”
附:
restful web services的介绍:http://xingshaomin.iteye.com/blog/127224
java的restful web services的实现项目jersey官网:https://jersey.dev.java.net/
sun官网关于restful web services的介绍:http://java.sun.com/developer/technicalArticles/WebServices/restful/
from:http://coolzhi.iteye.com/blog/588543