mirror of
https://github.com/apache/struts.git
synced 2026-08-06 07:06:58 +00:00
WW-1340 Streamline and extend "blank" for use with tutorial.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@440152 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+27
-8
@@ -15,24 +15,43 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.struts2.example;
|
||||
package example;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
* <code>HomeAction</code>
|
||||
* <code>Set welcome message.</code>
|
||||
*
|
||||
*/
|
||||
public class HomeAction extends ActionSupport {
|
||||
public class Welcome extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = -3881551454078687096L;
|
||||
|
||||
/**
|
||||
* A default implementation that does nothing an returns "success".
|
||||
*
|
||||
* @return {@link #SUCCESS}
|
||||
*/
|
||||
public static final String MESSAGE = "Struts is up and running ...";
|
||||
|
||||
public String execute() throws Exception {
|
||||
setMessage(MESSAGE);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field for Message property.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Return Message property.
|
||||
* @return Message property
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Message property.
|
||||
* @param message Text to display on Welcome page.
|
||||
*/
|
||||
public void setMessage(String message){
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,10 @@
|
||||
<struts>
|
||||
<include file="struts-default.xml"/>
|
||||
|
||||
<package name="default" extends="struts-default">
|
||||
<package name="example" extends="struts-default">
|
||||
|
||||
<default-action-ref name="home" />
|
||||
|
||||
<action name="home" class="org.apache.struts2.example.HomeAction">
|
||||
<result>/WEB-INF/pages/home.jsp</result>
|
||||
<action name="*" class="example.{1}">
|
||||
<result>/example/{1}.jsp</result>
|
||||
</action>
|
||||
|
||||
<!-- Add your actions here -->
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@
|
||||
<title>Welcome</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Struts is up and running...</h1>
|
||||
<h2><s:property value="message" /></h2>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +1 @@
|
||||
<% response.sendRedirect(request.getContextPath() + "/home.action"); %>
|
||||
<% response.sendRedirect(request.getContextPath() + "/Welcome.action"); %>
|
||||
|
||||
+36
-31
@@ -1,31 +1,36 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright 2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.struts2.example;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* <code>HomeActionTest</code>
|
||||
*
|
||||
*/
|
||||
public class HomeActionTest extends TestCase {
|
||||
|
||||
public void testHomeAction() throws Exception {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* $Id: WelcomeTest.java 418530 2006-07-01 23:58:13Z mrdon $
|
||||
*
|
||||
* Copyright 2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package example;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
* <code>WelcomeTest</code>
|
||||
*
|
||||
*/
|
||||
public class WelcomeTest extends TestCase {
|
||||
|
||||
public void testWelcome() throws Exception {
|
||||
Action welcome = new Welcome();
|
||||
String result = welcome.execute();
|
||||
assertTrue(ActionSupport.SUCCESS.equals(result));
|
||||
assertTrue(welcome.equals(Welcome.MESSAGE));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user