⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpheaderfieldkeytest.java

📁 自己写的一个struts+spring+hibernate测试程序
💻 JAVA
字号:
//I am willie

import java.io.IOException;

import java.net.URL;
import java.net.URLConnection;

import java.util.NoSuchElementException;

public class HttpHeaderFieldKeyTest {

	/**
     *  A test URL from which to get headers.
     */
    private static final String TEST_URL = "http://localhost:7080/pnews/MyJsp.jsp";
 
 	/**
     *  Index out of range.
     */
    private static final int INDEX = 1;
   
    /**
     *  Run the test, no arguments.
     */
    public static final void main(String[] args) {
    
        URL url = null;
        
        URLConnection connection = null;
        
        try {
        
            url = new URL(TEST_URL);
            
            connection = url.openConnection();
         
            connection.connect();   

            try {
 
                String header = connection.getHeaderFieldKey(INDEX);
        
                if (header == null) {

                    System.out.println("Test passes, method returned null.");
                }
                else {
        
                    System.err.println("Test fails, header at index " +
                                       INDEX + 
                                       " has value '" +
                                       header +
                                       "'.");
                }
            }
            catch (NoSuchElementException nsee) {
        
                System.err.println("Test fails, NoSuchElementException thrown.");
            }
        }
        catch (IOException ioe) {

            System.err.println("Test did not run, connection error for URL " +
                               TEST_URL);        
        }
        
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -