---
schema_version: "1"
id: 1e56495f48db69d255d7bb4c401b3623bc080323fc9cff455d8d74265f9e7421
title: 静的リソースの読み込みの例
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/http-connector/1.5/http-load-static-res-task.md
canonical_url: https://docs.mulesoft.com/jp/http-connector/1.5/http-load-static-res-task
source_site: docs.mulesoft.com
content_type: documentation
content_hash: c7b54b8ec74f3f4598868334e160bf06aaa0c59e98800b83af19f24d53cdef15
description: MuleSoft Documentation Site
release: "1.5"
latest: false
---
# 静的リソースの読み込みの例

次の例は、リソースをルックアップするための要求パスを使用して HTTP で使用する静的コンテンツを提供するように、HTTP 用 Anypoint Connector (HTTP Connector) の Listener ソースと Load static resource 操作を設定する方法を示しています。 この例を実行するには、Mule アプリケーションを作成し、HTTP グローバル要素を設定し、アプリケーションを実行し、curl コマンドでアプリケーションをテストする必要があります。

次のスクリーンショットは、この例の Anypoint Studio アプリケーションフローを示しています。

![静的リソースの読み込みのフロー](/mulesoft/current/ja-jp/http-connector/1.5/_images/http-loadresource-flow.png)

Figure 1. 静的リソースの読み込みのフロー

## [](#mule-アプリケーションの作成)Mule アプリケーションの作成

Mule フローを作成する手順は、次のとおりです。

1. **\[Mule Palette (Mule パレット)\]**​ ビューで、\[HTTP\] の ​**\[Listener\]**​ ソースを選択してキャンバスにドラッグします。  
    このソースは受信 HTTP メッセージ属性をリスンすることでフローを開始します。
2. Web ブラウザーからアプリケーションを開始するように ​**\[Path (パス)\]**​ 項目を ​`/trigger`​ に設定します。
3. **\[Connector configuration (コネクタ設定)\]**​ 項目の横にあるプラス記号 (​**+**​) をクリックして、アプリケーション内の HTTP の ​**Listener**​ のすべてのインスタンスで使用できるグローバル要素を設定します。
4. **\[General (一般)\]**​ タブで、次の項目を設定します。
    
    - **Host (ホスト)**​: `All Interfaces [0.0.0.0] (default)`
    - **Port (ポート)**​: `8081`
5. **\[OK\]**​ をクリックします。
    
    ![HTTP リスナーのグローバル設定](/mulesoft/current/ja-jp/http-connector/1.5/_images/http-startapp-example-1.png)
    
    Figure 2. HTTP リスナーのグローバル設定
6. **\[Load static resource\]**​ 操作を \[HTTP\] の ​**\[Listener\]**​ ソースの右にドラッグします。
7. **\[Resource base path (リソースベースパス)\]**​ 項目を ​`/Users/max/Sites/index.html`​ に設定します。
8. **\[Default file (デフォルトファイル)\]**​ 項目をリソースと同じディレクトリにあるバックアップファイルの名前 (​`index.html`​ など) に設定します。  
    Mule プロジェクトへの相対パスを使用する必要がある場合は、変数 ​`${app.workDir}`​ を使用します。例: `resourceBasePath="${app.workDir}/images/"`​。失敗した場合、アプリケーションはバックアップファイルを読み込みます。
    
    ![HTTP の Load static resource の設定](/mulesoft/current/ja-jp/http-connector/1.5/_images/http-loadresource-example-1.png)
    
    Figure 3. HTTP の Load static resource の設定
9. Mule アプリケーションを保存します。
10. **Package Explorer**​ でプロジェクト名をクリックし、​**\[Run (実行)\]**​ > ​**\[Run As (別のユーザーとして実行)\]**​ > ​**\[Mule Application (Mule アプリケーション)\]**​ をクリックします。
11. ブラウザーウィンドウで URL ​`http://0.0.0.0:8081/trigger`​ を入力します。  
    リソースのコンテンツがブラウザーに表示されます。

## [](#静的リソースを読み込むための-xml)静的リソースを読み込むための XML

この例のフローをすばやく Mule アプリケーションに読み込むには、次のコードを Studio XML エディターに貼り付けます。

```xml
<?xml version="1.0" encoding="UTF-8"?>


<mule xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<core:flow name="Flow" >
		<http:listener doc:name="Listener"  config-ref="HTTP_Listener_config"/>
		<http:load-static-resource doc:name="Load static resource" resourceBasePath="/Users/max/Sites/index.html" attributes="attributes"/>
	</core:flow>
</mule>
```

## [](#関連情報)関連情報

- [Anypoint Connector の概要](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)
- [MuleSoft ヘルプセンター](https://help.mulesoft.com)