LoginSignup
0
0

More than 5 years have passed since last update.

Struts2-tiles3-plugins を用いたアクション

Last updated at Posted at 2013-12-18

さくっとくんでみた。

設定ファイル等

IndexAction

package action;

import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;

@Namespace("/")
@ParentPackage("tiles-default")
@Action("index")
@Results({
        @Result(name = "success", location = "index_jsp", type = "tiles"),
        @Result(name = "input", location = "index_jsp", type = "tiles"),
        @Result(name = "error", location = "index_jsp", type = "tiles")
})
public class IndexAction extends ActionSupport implements SessionAware, SessionKey {

    protected Map<String, Object> session;

    @Override
    public String execute() throws Exception {

        return SUCCESS;
    }

    public void setSession(Map<String, Object> session) {
        this.session = session;
    }

}

index.jsp

<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
<%@ taglib prefix="tilesx" uri="http://tiles.apache.org/tags-tiles-extras"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
    <head>
        <s:head />
        <title>
            <tiles:insertAttribute name="TITLE" />
        </title>
    </head>
    <body>
        <h2>
            <tiles:insertAttribute name="TITLE"/>
        </h2>
    </body>
</html>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0