Top > SAStrutsあれこれ > 1-1 ○○さん、こんにちは!

  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
<?xml version="1.0"?>
 
<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
 
<struts-config>
<!--   ======================== * ** *** Form Bean Definitions -->
    <form-beans>
    </form-beans>
<!--   ================= * ** *** Global Exception Definitions -->
    <global-exceptions>
    </global-exceptions>
<!--   =================== * ** *** Global Forward Definitions -->
    <global-forwards>
    </global-forwards>
<!--   =================== * ** *** Action Mapping Definitions -->
    <action-mappings>
    </action-mappings>
    
<!--   ===================== * ** *** Controller Configuration -->
    <controller
        maxFileSize="1024K"
        bufferSize="1024"
        processorClass="org.seasar.struts.action.S2RequestProcessor"/>
<!--   ================ * ** *** Message Resources Definitions -->
    <message-resources parameter="application"
        factory="org.seasar.struts.util.S2PropertyMessageResourcesFactory"/>
<!--   ======================= * ** *** Plug Ins Configuration -->
    <plug-in className="org.seasar.struts.validator.S2ValidatorPlugIn">
        <set-property
          property="pathnames"
          value="/WEB-INF/validator-rules.xml"/>
    </plug-in>
</struts-config>

  0
  1
<!--   ================ * ** *** Message Resources Definitions -->
    <message-resources parameter="application"
        factory="org.seasar.struts.util.S2PropertyMessageResourcesFactory"/>
Everything is expanded.Everything is shortened.
  1
  2
  3
 
 
 
#HTMLから利用します。
greeting=こんにちは
welcome=ようこそ
Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hello World</title>
</head>
<body>
  <s:form>
    <bean:message key="greeting"/><br/>
    お名前をどうぞ。<br/><html:text property="name"/><br/>
    <html:submit property="submit">
      <bean:message key="greeting"/>
    </html:submit>
  </s:form>
</body>
</html>
Everything is expanded.Everything is shortened.
  1
 
<form name="helloActionForm" method="post" action="/sa-struts-hello/hello/">

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 
 
 
 
 
 
 
 
 
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="html" uri="http://struts.apache.org/tags-html"%>  
<%@taglib prefix="bean" uri="http://struts.apache.org/tags-bean"%>  
<%@taglib prefix="tiles" uri="http://jakarta.apache.org/struts/tags-tiles"%>
<%@taglib prefix="s" uri="http://sastruts.seasar.org" %>
<%@taglib prefix="f" uri="http://sastruts.seasar.org/functions" %>
Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hello World</title>
</head>
<body>
  <form name="helloActionForm" method="post" action="/sa-struts-hello/hello/">
    こんにちは<br/>
 
    お名前をどうぞ。<br/><input type="text" name="name" value=""><br/>
    <input type="submit" name="submit" value="こんにちは">
  </form>
</body>
</html>
Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
 
 
-
|
!
package hello.form;
 
public class HelloForm {
    public String name;
}

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 
 
 
 
 
 
 
-
|
|
|
|
|
|
|
|
|
-
|
!
|
|
|
|
-
|
!
!
package hello.action;
 
import hello.form.HelloForm;
import javax.annotation.Resource;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
 
public class HelloAction {
 
    //HelloFormのインスタンスが自動的にインジェクションされます。
    @ActionForm
    @Resource
    protected HelloForm helloForm;
 
    //名前入力画面の表示用
    // http://localhost:8080/sa-struts-hello/hello/ で呼ばれます。
    @Execute(validator = false)
    public String index() {
        return "hello.jsp";
    }
    
    //挨拶表示画面の表示用
    // http://localhost:8080/sa-struts-hello/submit/ で呼ばれます。
    @Execute(validator = false)
    public String submit() {
        return "helloWorld.jsp";
    }
}
Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 
 
 
 
 
 
 
 
 
 
 
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hello World</title>
</head>
<body>
  <h1>
    <bean:message key="welcome"/>
    ${f:h(name)}さん
  </h1>
</body>
</html>

Everything is expanded.Everything is shortened.
  1
 
${f:h(name)}さん

添付ファイル: filesuper1_1__4.jpg 380件 [詳細] filesuper1_1__3.jpg 435件 [詳細] filesuper1_1__2.jpg 335件 [詳細] filesuper1_1__1.jpg 406件 [詳細] filesuper1_1__0.jpg 425件 [詳細]

リロード   新規 編集 凍結解除 差分 添付 複製 名前変更   ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: 2012-08-08 (水) 23:25:50 (2925d)