質問編集履歴

3

消し忘れがあったため修正

2023/05/16 08:09

投稿

kazuuumi
kazuuumi

スコア4

test CHANGED
File without changes
test CHANGED
@@ -288,8 +288,6 @@
288
288
  }
289
289
 
290
290
  ```
291
- ```
292
-
293
291
  ### 補足情報(FW/ツールのバージョンなど)
294
292
  window11
295
293
  Eclips Version: 2023-03 (4.27.0)

2

ソース、設定ファイルの追記

2023/05/16 08:08

投稿

kazuuumi
kazuuumi

スコア4

test CHANGED
File without changes
test CHANGED
@@ -21,6 +21,274 @@
21
21
  一応classファイルがstruts2-rest-showcase\src\main\ImportedClasses\org\demo\rest\example配下にあるためそちらを指定しようとしましたがネストエラーで適用できませんでした。
22
22
  また実行時にビルドするよう設定されており、クリーン、リフレッシュ等を行っております。
23
23
 
24
+ ### コード
25
+ ```web.xml
26
+ <?xml version="1.0" encoding="UTF-8"?>
27
+ <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
28
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
29
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
30
+ http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
31
+ version="3.1">
32
+
33
+ <display-name>Struts 2 Rest Example</display-name>
34
+
35
+ <!-- Filters -->
36
+ <!-- START SNIPPET: filter -->
37
+ <filter>
38
+ <filter-name>action2</filter-name>
39
+ <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
40
+ </filter>
41
+ <!-- END SNIPPET: filter -->
42
+
43
+ <filter-mapping>
44
+ <filter-name>action2</filter-name>
45
+ <url-pattern>/*</url-pattern>
46
+ </filter-mapping>
47
+
48
+ <!-- Welcome file lists -->
49
+ <welcome-file-list>
50
+ <welcome-file>index.jsp</welcome-file>
51
+ </welcome-file-list>
52
+
53
+ <!-- Restricts access to pure JSP files - access available only via Struts action -->
54
+ <security-constraint>
55
+ <display-name>No direct JSP access</display-name>
56
+ <web-resource-collection>
57
+ <web-resource-name>No-JSP</web-resource-name>
58
+ <url-pattern>*.jsp</url-pattern>
59
+ </web-resource-collection>
60
+ <auth-constraint>
61
+ <role-name>no-users</role-name>
62
+ </auth-constraint>
63
+ </security-constraint>
64
+
65
+ <security-role>
66
+ <description>Don't assign users to this role</description>
67
+ <role-name>no-users</role-name>
68
+ </security-role>
69
+
70
+ </web-app>
71
+
72
+ ```
73
+ ```pom.xml
74
+ <?xml version="1.0" encoding="UTF-8"?>
75
+
76
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
77
+ <modelVersion>4.0.0</modelVersion>
78
+ <parent>
79
+ <groupId>org.apache.struts</groupId>
80
+ <artifactId>struts2-apps</artifactId>
81
+ <version>6.1.2</version>
82
+ </parent>
83
+
84
+ <artifactId>struts2-rest-showcase</artifactId>
85
+ <packaging>war</packaging>
86
+ <version>6.1.2</version>
87
+ <name>Struts 2 Rest Showcase Webapp</name>
88
+ <description>Struts 2 Rest Showcase Example</description>
89
+
90
+ <dependencies>
91
+ <dependency>
92
+ <groupId>org.apache.struts</groupId>
93
+ <artifactId>struts2-rest-plugin</artifactId>
94
+ </dependency>
95
+ <dependency>
96
+ <groupId>org.apache.struts</groupId>
97
+ <artifactId>struts2-convention-plugin</artifactId>
98
+ </dependency>
99
+ <dependency>
100
+ <groupId>org.apache.struts</groupId>
101
+ <artifactId>struts2-config-browser-plugin</artifactId>
102
+ </dependency>
103
+
104
+ <dependency>
105
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
106
+ <artifactId>jackson-dataformat-xml</artifactId>
107
+ </dependency>
108
+
109
+ <!-- Logging -->
110
+ <dependency>
111
+ <groupId>org.apache.logging.log4j</groupId>
112
+ <artifactId>log4j-api</artifactId>
113
+ <version>${log4j2.version}</version>
114
+ </dependency>
115
+ <dependency>
116
+ <groupId>org.apache.logging.log4j</groupId>
117
+ <artifactId>log4j-core</artifactId>
118
+ <version>${log4j2.version}</version>
119
+ </dependency>
120
+
121
+ <dependency>
122
+ <groupId>junit</groupId>
123
+ <artifactId>junit</artifactId>
124
+ <scope>test</scope>
125
+ </dependency>
126
+
127
+ <dependency>
128
+ <groupId>net.sourceforge.jwebunit</groupId>
129
+ <artifactId>jwebunit-core</artifactId>
130
+ <version>3.3</version>
131
+ <scope>test</scope>
132
+ </dependency>
133
+
134
+ <dependency>
135
+ <groupId>net.sourceforge.htmlunit</groupId>
136
+ <artifactId>htmlunit</artifactId>
137
+ <version>2.39.0</version>
138
+ <scope>test</scope>
139
+ </dependency>
140
+
141
+ <dependency>
142
+ <groupId>net.sourceforge.jwebunit</groupId>
143
+ <artifactId>jwebunit-htmlunit-plugin</artifactId>
144
+ <version>3.3</version>
145
+ <scope>test</scope>
146
+ <exclusions>
147
+ <exclusion>
148
+ <groupId>xom</groupId>
149
+ <artifactId>xom</artifactId>
150
+ </exclusion>
151
+ <!-- not necessary to compile and it force dependency convergence issues -->
152
+ <exclusion>
153
+ <groupId>net.sourceforge.htmlunit</groupId>
154
+ <artifactId>htmlunit</artifactId>
155
+ </exclusion>
156
+ </exclusions>
157
+ </dependency>
158
+
159
+ </dependencies>
160
+
161
+ <build>
162
+ <finalName>struts2-rest-showcase</finalName>
163
+ <!--
164
+ <outputDirectory>src\main\ImportedClasses\org\demo\rest\example</outputDirectory>
165
+ -->
166
+ <plugins>
167
+ <plugin>
168
+ <groupId>org.eclipse.jetty</groupId>
169
+ <artifactId>jetty-maven-plugin</artifactId>
170
+ <version>9.4.46.v20220331</version>
171
+ <configuration>
172
+ <stopKey>CTRL+C</stopKey>
173
+ <stopPort>8999</stopPort>
174
+ <scanIntervalSeconds>10</scanIntervalSeconds>
175
+ <webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
176
+ <webAppConfig>
177
+ <contextPath>/struts2-rest-showcase</contextPath>
178
+ <descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
179
+ </webAppConfig>
180
+ </configuration>
181
+ </plugin>
182
+ <plugin>
183
+ <artifactId>maven-surefire-plugin</artifactId>
184
+ <configuration>
185
+ <argLine>@{argLine}</argLine>
186
+ <excludes>
187
+ <exclude>it/**</exclude>
188
+ <exclude>**/*$*</exclude>
189
+ </excludes>
190
+ </configuration>
191
+ </plugin>
192
+ </plugins>
193
+ </build>
194
+ <properties>
195
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
196
+ </properties>
197
+ </project>
198
+
199
+ ```
200
+
201
+ ```Order.java
202
+
203
+ package org.demo.rest.example;
204
+
205
+ import org.apache.commons.lang3.builder.EqualsBuilder;
206
+ import org.apache.commons.lang3.builder.HashCodeBuilder;
207
+ import org.apache.commons.lang3.builder.ToStringBuilder;
208
+
209
+ public class Order {
210
+ String id;
211
+ String clientName;
212
+ String orderDetail;
213
+ int amount;
214
+
215
+ public Order() {}
216
+
217
+ public Order(String id, String clientName, int amount) {
218
+ super();
219
+ this.id = id;
220
+ this.clientName = clientName;
221
+ this.orderDetail = orderDetail;
222
+ this.amount = amount;
223
+ }
224
+ public int getAmount() {
225
+ return amount;
226
+ }
227
+ public void setAmount(int amount) {
228
+ this.amount = amount;
229
+ }
230
+ public String getClientName() {
231
+ return clientName;
232
+ }
233
+ public void setClientName(String clientName) {
234
+ this.clientName = clientName;
235
+ }
236
+ public String getOrderDetail() {
237
+ return orderDetail;
238
+ }
239
+ public void setOrderDetail(String orderDetail) {
240
+ this.orderDetail = orderDetail;
241
+ }
242
+ public String getId() {
243
+ return id;
244
+ }
245
+ public void setId(String id) {
246
+ this.id = id;
247
+ }
248
+
249
+ @Override
250
+ public boolean equals(Object obj) {
251
+ if (obj == null) {
252
+ return false;
253
+ }
254
+ if (obj == this) {
255
+ return true;
256
+ }
257
+ if (obj.getClass() != getClass()) {
258
+ return false;
259
+ }
260
+ Order rhs = (Order) obj;
261
+ return new EqualsBuilder()
262
+ .append(this.id, rhs.id)
263
+ .append(this.clientName, rhs.clientName)
264
+ .append(this.orderDetail, rhs.orderDetail)
265
+ .append(this.amount, rhs.amount)
266
+ .isEquals();
267
+ }
268
+
269
+ @Override
270
+ public int hashCode() {
271
+ return new HashCodeBuilder()
272
+ .append(id)
273
+ .append(clientName)
274
+ .append(orderDetail)
275
+ .append(amount)
276
+ .toHashCode();
277
+ }
278
+
279
+ @Override
280
+ public String toString() {
281
+ return new ToStringBuilder(this)
282
+ .append("id", id)
283
+ .append("clientName", clientName)
284
+ .append("orderDetail", orderDetail)
285
+ .append("amount", amount)
286
+ .toString();
287
+ }
288
+ }
289
+
290
+ ```
291
+ ```
24
292
 
25
293
  ### 補足情報(FW/ツールのバージョンなど)
26
294
  window11

1

コメントにてご指摘がありましたか所に関して追記

2023/05/16 07:29

投稿

kazuuumi
kazuuumi

スコア4

test CHANGED
File without changes
test CHANGED
@@ -4,12 +4,17 @@
4
4
 
5
5
  ### 前提
6
6
 
7
- ここに質問の内容を詳しく書いてください。
8
- 公式サイトから取得したFull Distributionのstruts2-rest-showcaseをEclipsにて開き、struts2-rest-showcase\src\main\webapp\WEB-INF\src\java\org\demo\rest\example配下のソースとjspファイルを少し修正を行いました。
9
- ほかのwebアプリ同様サーバーで実行を行った際にコンパイルされ自動的にclassファイルの更新がかかると思ったのですが更新されておりません。
10
- 実行時にはエラー等が起こっていないため問題ないと思っていたのですがなぜでしょうか?
11
- 上記ソース以外は公式のものをそのまま使用しています。なので実行すれば稼働することは確認済みですが反映されておりません
12
7
 
8
+ struts2の公式サイトから取得したFull Distributionのstruts2-rest-showcaseをEclipsにて開き、struts2-rest-showcase\src\main\webapp\WEB-INF\src\java\org\demo\rest\example配下のソースとjspファイルを少し修正を行いました。
9
+ →こちらに関しましてはJSPのテーブルにてカラムを一つ追加し、それに伴う修正を行った形です。
10
+
11
+ ほかのwebアプリ同様「サーバーで実行」を行った際にコンパイルされ自動的にclassファイルの更新がかかると思ったのですが更新されておりません。
12
+ →struts2-rest-showcase\src\main\ImportedClasses\org\demo\rest\example配下のclassファイルの更新日時に変化がないため「更新されていない」と判断しております。
13
+
14
+ 実行時にはエラー等が起こらずに起動してJSPのみ反映された形で画面が表示されました。
15
+ 上記ソース以外は公式のものをそのまま使用しています。
16
+ 下記トップ画面
17
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-05-16/5fdbdcf4-6fb8-474d-b1b1-fb1e9d6eebdb.png)
13
18
 
14
19
  ### 試したこと
15
20
  ビルドの出力先が違うのかと思い変更しようとしましたが、struts2-rest-showcase\build\classesとなっているので問題ないとおもいます。