2015年6月24日水曜日

authorized_keysファイルとは

authorized_keysファイルとは

主に公開鍵を保存するためのですが、ログイン時に自動的に実行するプログラムを入れたり、環境変数を入れたりすることもできるファイルです。

2015年6月7日日曜日

Chromebブラウザで「No 'Access-Control-Allow-Origin' header is present on the requested resource」エラーの解決方法

chromeのブラウザでrest apiを呼んだら、こんなエラーが出た

No 'Access-Control-Allow-Origin' header is present on the requested resource

エラーの解消方法は、
Windowsユーザーの場合は、
こんな感じで起動すれば解決できるはずです。

chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
他の環境、マックユーザーなどの場合は、
ChromeのプラグインCORSをインストールして、
後そのプラグインの設定のところ、「Enable cross-origin resource sharing 」ONにすれば解決できるはずです。
CORSのプラグインURLは以下の通りです。
https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en-US)

Spring Restfull APIで200 OKレスポンスを返す方法

関数にアノテーション「@ResponseStatus(HttpStatus.OK)」を追加
関数の返却値は「void」で定義する

例:
@RequestMapping(value = “/xxxx/{Id:.+}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public void delete(@RequestHeader(“code") final String code, @PathVariable final String Id) throws ApplicationException{
    // 処理
    try {
        
    } catch (ApplicationException e) {
        
        }
    }
}