Skip to content

Commit 4647a1a

Browse files
committed
Refactor(unit-testing): Update for Struts 7 compatibility
- Modified access to `register.jsp` to go through the `registerForm` Action, as Struts form tags are used. - Update `web.xml` to schema version 6.0. - Change JSP file encoding to `UTF-8`.
1 parent 9e1e13a commit 4647a1a

5 files changed

Lines changed: 20 additions & 14 deletions

File tree

unit-testing/src/main/resources/struts.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88
<constant name="struts.devMode" value="true"/>
99

1010
<package name="basicstruts2" extends="struts-default">
11-
11+
<default-action-ref name="index"/>
1212
<!-- If no class attribute is specified the framework will assume success and
1313
render the result index.jsp -->
1414
<!-- If no name value for the result node is specified the success value is the default -->
1515
<action name="index">
1616
<result>/index.jsp</result>
1717
</action>
1818

19+
<action name="registerForm" class="org.apache.struts.register.action.Register" method="input">
20+
<result name="input">/register.jsp</result>
21+
</action>
1922

2023
<action name="register" class="org.apache.struts.register.action.Register" method="execute">
2124
<result name="success">/thankyou.jsp</result>

unit-testing/src/main/webapp/WEB-INF/web.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
2+
<web-app id="WebApp_ID" version="6.0"
3+
xmlns="https://jakarta.ee/xml/ns/jakartaee"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
36
<display-name>Struts 2 Unit Testing</display-name>
47
<welcome-file-list>
58
<welcome-file>index.jsp</welcome-file>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2-
pageEncoding="ISO-8859-1"%>
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
33
<%@ taglib prefix="s" uri="/struts-tags" %>
44
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
55
<html>
66
<head>
7-
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
7+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
88
<title>Basic Struts 2 Application - Welcome</title>
99
</head>
1010
<body>
1111
<h1>Welcome To Struts 2!</h1>
1212

1313

1414

15-
<p><a href="register.jsp">Please register</a> for our prize drawing.</p>
15+
<p><a href="<s:url action='registerForm' />">Please register</a> for our prize drawing.</p>
1616
</body>
1717
</html>

unit-testing/src/main/webapp/register.jsp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<?xml version="1.0" encoding="ISO-8859-1" ?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22
<%@ taglib prefix="s" uri="/struts-tags" %>
3-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
4-
pageEncoding="ISO-8859-1"%>
3+
<%@ page language="java" contentType="text/html; charset=UTF-8"
4+
pageEncoding="UTF-8"%>
55
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
66
<html xmlns="http://www.w3.org/1999/xhtml">
77
<head>
8-
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
8+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
99
<title>Register</title>
1010
<s:head />
1111
</head>

unit-testing/src/main/webapp/thankyou.jsp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<?xml version="1.0" encoding="ISO-8859-1" ?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22
<%@ taglib prefix="s" uri="/struts-tags" %>
3-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
4-
pageEncoding="ISO-8859-1"%>
3+
<%@ page language="java" contentType="text/html; charset=UTF-8"
4+
pageEncoding="UTF-8"%>
55
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
66
<html xmlns="http://www.w3.org/1999/xhtml">
77
<head>
8-
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
8+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
99
<title>Registration Successful</title>
1010
</head>
1111
<body>

0 commit comments

Comments
 (0)