以下示例有什么问题?
问题是解密字符串的第一部分是无意义的.但是,剩下的很好,我明白了......
Run Code Online (Sandbox Code Playgroud)Result: `£eB6O?geS??i are you? Have a nice day.
@Test
public void testEncrypt() {
try {
String s = "Hello there. How are you? Have a nice day.";
// Generate key
KeyGenerator kgen = KeyGenerator.getInstance("AES");
kgen.init(128);
SecretKey aesKey = kgen.generateKey();
// Encrypt cipher
Cipher encryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
encryptCipher.init(Cipher.ENCRYPT_MODE, aesKey);
// Encrypt
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
CipherOutputStream cipherOutputStream = new CipherOutputStream(outputStream, encryptCipher);
cipherOutputStream.write(s.getBytes());
cipherOutputStream.flush();
cipherOutputStream.close();
byte[] encryptedBytes = outputStream.toByteArray();
// Decrypt cipher
Cipher decryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
IvParameterSpec ivParameterSpec = …Run Code Online (Sandbox Code Playgroud) 我在Jersey Resource类中实现了流输出.
@GET
@Path("xxxxx")
@Produces(BulkConstants.TEXT_XML_MEDIA_TYPE})
public Response getFile() {
FeedReturnStreamingOutput sout = new FeedReturnStreamingOutput();
response = Response.ok(sout).build();
return response;
}
class FeedReturnStreamingOutput implements StreamingOutput {
public FeedReturnStreamingOutput()
@Override
public void write(OutputStream outputStream) {
//write into Output Stream
}
}
Run Code Online (Sandbox Code Playgroud)
问题是尽管在调用FeedReturnStreamingOutput之前从资源发回响应但是Jersey客户端等待直到FeedReturnStreamingOutput执行完成.
客户代码:
Client client = Client.create();
ClientResponse response = webResource
//headers
.get(ClientResponse.class);
//The codes underneath executes after FeedReturnStreamingOutput is executed which undermines the necessity of streaming
OutputStream os = new FileOutputStream("c:\\test\\feedoutput5.txt");
System.out.println(new Date() + " : Reached point A");
if (response.getStatus() …Run Code Online (Sandbox Code Playgroud) 我有一个房产
@JsonProperty
private Map<String, String> parameters = new HashMap<String, String>();
Run Code Online (Sandbox Code Playgroud)
当我尝试通过调用objectMapper.readValue(...)进行反序列化时,一切正常,直到JSON中的参数字段为空,即.
"parameters":[]
Run Code Online (Sandbox Code Playgroud)
我得到这个例外......
org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.HashMap out of START_ARRAY token
Run Code Online (Sandbox Code Playgroud)
我该如何处理空列表?不,我对JSON的控制没有任何控制权.
谢谢.
我正在忍受无法解决的maven-protoc-plugin问题,os.detected.classifier导致日食报告我的pom错误。
我找到了此修复程序,但我怀疑它仅适用于较旧的Eclipse版本,<eclipse>/plugins氧气中不再有文件夹。
我尝试os.detected.classifier在eclipse.ini和Windows环境变量中进行设置均无济于事。
这是一些认为会有所帮助的pom的剪辑。
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.3.0.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>0.4.3</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
Run Code Online (Sandbox Code Playgroud)
还有部分错误...
Missing:
----------
1) com.google.protobuf:protoc:exe:${os.detected.classifier}:2.6.1
Try downloading the file manually from the project website.
Run Code Online (Sandbox Code Playgroud) 我做了一个像下面这样的线程:
public class MyThread implements Runnable {
private int temp;
public MyThread(int temp){
this.temp=temp;
}
@Override
public void run() {
temp+=10;
return;
}
public int getTemp() {
return temp;
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试通过 getTemp 使用 temp 时,我得到 0
class Main {
MyThread foo = new MyThread(10);
Thread a = new Thread(foo);
a.start();
int aa = foo.getTemp();
System.out.println(aa);
}
Run Code Online (Sandbox Code Playgroud)
我只想使用我在线程中所做的计算存储在一些变量中以备后用。
当我调用setState并且重新呈现表单时,文本输入的值不会更改。
import React, { Component } from 'react';
import { Button, Col, Form, Row } from 'react-bootstrap';
export default class Test extends Component {
constructor(props) {
super(props);
this.state = {
status: "new"
}
}
approve = (e) => {
this.setState({
status: "I'm newer than you!"
});
e.preventDefault();
}
render() {
return (
<div>
Status is {this.state.status}
<Form onSubmit={this.approve}>
<Form.Group as={Row} controlId="status">
<Form.Label column >Status</Form.Label>
<Col>
<Form.Control readOnly type="text" size="sm" defaultValue={this.state.status} />
</Col>
</Form.Group>
<Form.Group as={Row}>
<Button type="submit">approve</Button>
</Form.Group> …Run Code Online (Sandbox Code Playgroud) 我有以下2种方法...
@GET
@Path("/{solution}")
public Response test(@PathParam("solution") String solution,
@Context UriInfo uriInfo, @Context HttpHeaders headers);
@GET
@Path("/{solution}/{path:[a-z0-9/\\-]*}")
public Response testTest(@PathParam("solution") String solution,
@PathParam("path") String nodePath,
@Context UriInfo uriInfo, @Context HttpHeaders headers);
Run Code Online (Sandbox Code Playgroud)
当我调用/ my-app / test / test时,第二个方法被调用并且参数设置正确。当我调用/ my-app / test而不是第一个方法被调用时,我收到未找到的HTTP 405方法。我假设它正在将URL映射到其他方法之一,例如。
@DELETE
@Path("{path: [a-z0-9/\\-]*}")
public Response deleteTest(@PathParam("path") String path, @Context HttpHeaders headers);
Run Code Online (Sandbox Code Playgroud)
有人发现我做错了吗?任何人都可以找到jersey试图映射到的方法的任何提示?
谢谢。