Struts 2 <s:hidden>隠し値の例

Struts 2 隠し値の例

ダウンロード–Struts2-Hidden-Example.zip

Struts 2では、<s:hidden>タグを使用してHTML非表示フィールドを作成できます。

次のHTMLコードとしてレンダリングされます。

Struts 2 の例

URLの非表示値を持つページ。フォームが送信された後に非表示値を表示します。

1. アクション

HiddenAction.java

package com.example.common.action;

import com.opensymphony.xwork2.ActionSupport;

public class HiddenAction extends ActionSupport{

    private String url;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String execute() {
        return SUCCESS;
    }

}

2. ページを見る

Struts 2の「s:hidden」タグを使用して、非表示の値フィールドを作成します。

hidden.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>





Struts 2 - hidden value example

This page has a hidden value (view source):

welcome.jsp

<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>



Struts 2 - hidden value example

The hidden value :

3. struts.xml

一緒にリンクしてください〜





   

   
    
        pages/hidden.jsp
    
    
        pages/welcome.jsp