mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
WW-2702 Codebehind unknown handler can now instantiate PackageConfig.defaultClassRef instead of only ActionSupport.
Rest plugin provides defaultClassImpl impl with index() method to support unknown actions. git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@673081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+2
-2
@@ -75,7 +75,7 @@ public class CodebehindUnknownHandler implements UnknownHandler {
|
||||
public void setPathPrefix(String prefix) {
|
||||
this.templatePathPrefix=prefix;
|
||||
}
|
||||
|
||||
|
||||
@Inject
|
||||
public void setServletContext(ServletContext servletContext) {
|
||||
this.servletContext = servletContext;
|
||||
@@ -110,7 +110,7 @@ public class CodebehindUnknownHandler implements UnknownHandler {
|
||||
/** Create a new ActionConfig in the default package, with the default interceptor stack and a single result */
|
||||
protected ActionConfig buildActionConfig(String path, String namespace, String actionName, ResultTypeConfig resultTypeConfig) {
|
||||
final PackageConfig pkg = configuration.getPackageConfig(defaultPackageName);
|
||||
return new ActionConfig.Builder(defaultPackageName, "execute", ActionSupport.class.getName())
|
||||
return new ActionConfig.Builder(defaultPackageName, "execute", pkg.getDefaultClassRef())
|
||||
.addInterceptors(InterceptorBuilder.constructInterceptorReference(new InterceptorLocator() {
|
||||
public Object getInterceptorConfig(String name) {
|
||||
return pkg.getAllInterceptorConfigs().get(name); // recurse package hiearchy
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.rest;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
* Extends {@link ActionSupport} to provides a default implementation of the index method that can be invoked for
|
||||
* unknown actions by the {@link com.opensymphony.xwork2.UnknownHandler}.
|
||||
*/
|
||||
public class RestActionSupport extends ActionSupport {
|
||||
|
||||
public String index() throws Exception {
|
||||
return execute();
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@
|
||||
<constant name="struts.codebehind.classSuffix" value="Controller"/>
|
||||
<constant name="struts.codebehind.action.checkImplementsAction" value="false"/>
|
||||
<constant name="struts.codebehind.action.checkAnnotation" value="false"/>
|
||||
<constant name="struts.codebehind.action.defaultMethodName" value="index"/>
|
||||
|
||||
<constant name="struts.configuration.classpath.defaultParentPackage" value="rest-default" />
|
||||
|
||||
@@ -112,6 +113,9 @@
|
||||
</interceptors>
|
||||
|
||||
<default-interceptor-ref name="restDefaultStack"/>
|
||||
|
||||
<default-class-ref class="org.apache.struts2.rest.RestActionSupport"/>
|
||||
|
||||
</package>
|
||||
|
||||
</struts>
|
||||
|
||||
Reference in New Issue
Block a user