我需要使用RESTTemplate将自定义对象传递给我的REST服务.
RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, Object> requestMap = new LinkedMultiValueMap<String, Object>();
...
requestMap.add("file1", new FileSystemResource(..);
requestMap.add("Content-Type","text/html");
requestMap.add("accept", "text/html");
requestMap.add("myobject",new CustomObject()); // This is not working
System.out.println("Before Posting Request........");
restTemplate.postForLocation(url, requestMap);//Posting the data.
System.out.println("Request has been executed........");
Run Code Online (Sandbox Code Playgroud)
我无法将自定义对象添加到MultiValueMap.请求生成失败.
有人可以帮我找到一个方法吗?我可以简单地传递一个字符串对象而没有问题.用户定义的对象会产生问题.
感谢任何帮助!
当我的JDK版本升级到u45时,我收到有关缺少安全信息的警告.因此,我使用以下安全更新作为使用webstart-maven-plugin进行webstart签名的一部分
<plugin>
<groupId> org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>1.0-beta-4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jnlp-inline</goal>
<!-- use jnlp, jnlp-inline or jnlp-single as appropriate -->
</goals>
</execution>
</executions>
<configuration>
<!--outputDirectory></outputDirectory -->
<!-- not required?? -->
<!-- Set to true to exclude all transitive dependencies. Default is
false. -->
<excludeTransitive>false</excludeTransitive>
<!-- The path where the libraries are stored within the jnlp structure.
not required. by default the libraries are within the working directory -->
<libPath>lib</libPath>
<!-- resourcesDirectory>${project.basedir}/src/main/jnlp/resources</resourcesDirectory -->
<!-- default value -->
<!-- JNLP generation --> …Run Code Online (Sandbox Code Playgroud) java jnlp jar-signing maven-jar-plugin maven-webstart-plugin
我知道有状态bean在不同的实例方法调用之间保持对话会话,但是无状态不会.我的问题,假设我有一个无状态bean实现,如下所示
import javax.ejb.Stateful;
import javax.ejb.Stateless;
import com.tata.ejb3.data.HelloEJBInterface;
@Stateless
public class ValueEJB implements ValueEJBInterface{
private int value;
@Override
public int getValue() {
return this.value;
}
@Override
public void setValue(int value) {
this.value = value;
}
}
Run Code Online (Sandbox Code Playgroud)
我有我的bean客户端(一个servlet),它启动bean调用,如下所示
@EJB(mappedName="E/ValueEJB /remote")
ValueEJBInterface value;
....
value.setValue(250);
System.out.println(value.getValue());//This statement prints the value 250
....
Run Code Online (Sandbox Code Playgroud)
根据我的理解,因为我的bean是无状态bean,它不应该以250的值显示.
私有int值; 是一个即时变量,如果一个无状态方法设置其值,则该值将在方法exit上过期.但是在这里,即使通过我的第二个方法调用,我也能得到值'250'.这是违反无国籍概念的吗?我缺少什么吗?
ejb-3.0 ×1
jar-signing ×1
java ×1
jnlp ×1
rest-client ×1
resttemplate ×1
spring-3 ×1
spring-mvc ×1