-
-
Save zhanggang807/a7c041de610948f8a5a342470c5b3156 to your computer and use it in GitHub Desktop.
@smd annotation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<!DOCTYPE struts PUBLIC | |
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" | |
"http://struts.apache.org/dtds/struts-2.0.dtd"> | |
<struts> | |
<package name="example" namespace="/example" extends="default"> | |
<action name="HelloWorld" class="example.HelloWorld"> | |
<result>/example/HelloWorld.jsp</result> | |
</action> | |
<action name="Login_*" method="{1}" class="example.Login"> | |
<result name="input">/example/Login.jsp</result> | |
<result type="redirectAction">Menu</result> | |
</action> | |
<action name="*" class="example.ExampleSupport"> | |
<result>/example/{1}.jsp</result> | |
</action> | |
<!-- Add actions here --> | |
</package> | |
<constant name="struts.ognl.allowStaticMethodAccess" value="true"/> | |
<package name="example2" namespace="/example2" extends="json-default"> | |
<action name="smdAction" class="example.SMDAction" method="smd"> | |
<interceptor-ref name="json"> | |
<param name="enableSMD">true</param> | |
<param name="ignoreSMDMethodInterfaces">false</param> | |
</interceptor-ref> | |
<result type="json"> | |
<param name="enableSMD">true</param> | |
<param name="contentType">text/html</param> | |
<param name="ignoreInterfaces">false</param> | |
</result> | |
</action> | |
</package> | |
</struts> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"methods":[ | |
{ | |
"name":"method1", | |
"parameters":[ | |
{ | |
"name":"p0" | |
} | |
] | |
}, | |
{ | |
"name":"method2", | |
"parameters":[ | |
{ | |
"name":"p0" | |
} | |
] | |
} | |
], "objectName":"testaction", | |
"serviceType":"JSON-RPC", | |
"serviceUrl":"\/struts2-blank\/example2\/smdAction.action", | |
"version":"10.0"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
/* | |
* $Id: pom.xml 1337583 2012-05-12 16:06:55Z lukaszlenart $ | |
* | |
* 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. | |
*/ | |
--> | |
<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"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>org.apache.struts</groupId> | |
<artifactId>struts2-apps</artifactId> | |
<version>2.3.5-SNAPSHOT</version> | |
</parent> | |
<groupId>org.apache.struts</groupId> | |
<artifactId>struts2-blank</artifactId> | |
<packaging>war</packaging> | |
<name>Blank Webapp</name> | |
<scm> | |
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/blank/</connection> | |
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/apps/blank/</developerConnection> | |
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/apps/blank/</url> | |
</scm> | |
<dependencies> | |
<dependency> | |
<groupId>javax.servlet</groupId> | |
<artifactId>servlet-api</artifactId> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>javax.servlet</groupId> | |
<artifactId>jsp-api</artifactId> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>${project.groupId}</groupId> | |
<artifactId>struts2-json-plugin</artifactId> | |
<version>${project.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>${project.groupId}</groupId> | |
<artifactId>struts2-junit-plugin</artifactId> | |
<version>${project.version}</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.mortbay.jetty</groupId> | |
<artifactId>maven-jetty-plugin</artifactId> | |
<version>6.0.1</version> | |
<configuration> | |
<scanIntervalSeconds>10</scanIntervalSeconds> | |
<scanTargets> | |
<scanTarget>src/main/webapp/WEB-INF</scanTarget> | |
<scanTarget>src/main/webapp/WEB-INF/web.xml</scanTarget> | |
<scanTarget>src/main/resources/struts.xml</scanTarget> | |
<scanTarget>src/main/resources/example.xml</scanTarget> | |
</scanTargets> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* $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 example; | |
import com.opensymphony.xwork2.Action; | |
import org.apache.struts2.json.annotations.SMD; | |
import org.apache.struts2.json.annotations.SMDMethod; | |
import java.util.List; | |
/** | |
* User: mcucchiara | |
* Date: 24/09/12 | |
* Time: 9.59 | |
*/ | |
/* Following annotation seems to not working*/ | |
@SMD(objectName = "testaction", serviceType = "JSON-RPC", version = "10.0") | |
public class SMDAction { | |
public SMDAction() { | |
} | |
public String smd() { | |
return Action.SUCCESS; | |
} | |
@SMDMethod | |
public Object[] method1(List<String> fruits) { | |
return null; | |
} | |
@SMDMethod | |
public Object[] method2(List<String> animals) { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment