我正在使用具有云功能的收据打印机。它与我正在实施的服务器规范相通讯。它每x秒用POST请求轮询URL,并且POST响应中包含某条信息时,打印机将GET请求发送到该URL,以获取要打印的信息。
我将打印服务器实现为Spring Boot服务器,而POST方法遇到一些奇怪的问题,我需要一些帮助。
我的问题是从打印机到服务器的POST请求从不发送到控制器。但是,我能够将Postman的POST请求发送到完全相同的URL,并由控制器处理。
该URL就是:https:// www。[my-domain] .com:[port-number] / cloudprint
另外,我尝试将控制器方法复制到另一个在Apache后面的Tomcat实例上运行的Spring(不是Boot)应用程序中,并且打印机的POST请求由控制器方法处理。我可以在Apache日志和Tomcat日志中看到它们。当前的轮询频率为10秒。
控制器的外观如下:
package com.[my-domain].[application-name].controller;
[a bunch of imports]
@RestController
@CrossOrigin
public class PrintController {
Logger logger = LoggerFactory.getLogger(PrintController.class);
@RequestMapping(value="/cloudprint", method=RequestMethod.POST,
headers={"Accept=application/json"})
@ResponseStatus(HttpStatus.CREATED)
public @ResponseBody String printPost() {
logger.debug("in printPost");
return "OK";
}
@RequestMapping(value="/cloudprint", method=RequestMethod.GET,
headers={"Accept=application/json"})
@ResponseStatus(HttpStatus.OK)
public @ResponseBody String printGet(HttpServletRequest request) {
logger.debug("in printGet");
return "OK";
}
@RequestMapping(value="/cloudprint", method=RequestMethod.DELETE,
headers={"Accept=application/json"})
@ResponseStatus(HttpStatus.OK)
public @ResponseBody String printDelete() {
logger.debug("in printDelete");
return "OK";
}
}
Run Code Online (Sandbox Code Playgroud)
是什么原因造成的?我可以测试什么来解决此问题?
---添加的信息低于2019-06-03 @ 13:21 cet ---由于我有一个常规的Spring(non-boot)应用程序,可以接受来自打印机的POST请求,因此我可以将信息记录在接收到的信息中请求。所以我做到了。
这是来自打印机的POST请求之一,Spring boot …
我正在开发我的第一个Spring Boot应用程序,我遇到了一个奇怪的问题.配置非常基础:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pawsec</groupId>
<artifactId>kitchen</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>kitchen</name>
<description>The Kitchen restaurant system</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pawsec</groupId>
<artifactId>common</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
我们在调用这两个服务的页面上有一些Javascript代码.当控制器在第一个方法中返回Guy对象时,我们得到一个空响应:
{data: …Run Code Online (Sandbox Code Playgroud) 我们是一家小公司,开发具有应用程序作为用户界面的应用程序.后端是Java服务器.我们有Android和Iphone版本的应用程序,我们一直在努力保持它们在功能方面同步,并保持类似的外观,而不会干扰每个平台上的标准和最佳实践.大多数应用程序开发都是由分包商完成的.
现在,我们与使用Corona构建应用程序的公司展开了对话,Corona是一个用于在一个地方构建应用程序并从那里生成Iphone和Android应用程序的框架.他们告诉我们它是如此快速和简单,一切都很棒.Corona Labs网站告诉我几乎一样的.
但是我在职业生涯早期见过这种产品,所以我有点怀疑.此外,我已经看到了销售人员所说的与真相之间的差距.我想我会在这里提出这个问题,并希望从那些了解更多相关信息的人那里获得一些意见.请分享您的知识和想法.
我们有一个应用程序在审核过程中被 Apple 应用程序审核人员拒绝。拒绝的原因是应用程序在 Ipad 上运行时没有正确缩放。
该应用程序从未打算在 Ipad 上运行,但与他们争论这一点似乎没有意义。
Apple 向我们发送了几个屏幕截图,显示我们的应用程序在 Ipad 上运行,并且视图的顶部被切断了。请注意该应用程序是如何在某种模式下运行的,它看起来像一个 Iphone 应用程序并且没有填满整个显示区域。当我们在 Ipad 上打开应用程序时,它会填满整个屏幕,并且不会切断任何边缘。
谁能告诉我如何像苹果公司那样在 Ipad 上运行应用程序 - Iphone 大小?我们相信我们已经修复了该问题,但我们需要重现该错误,然后才能验证该修复是否解决了该问题。
(图片中的标识是故意模糊的)

我有一个关于 Android 中的 OkHttp 及其对字符编码的支持的问题,特别是使用 UTF-8 来支持瑞典字符 å、ä 和 ö(以及大写字母 ÅÄÖ)。
我们正在构建的应用程序使用 OkHttp 对我们的服务器系统进行 GET 和 POST 调用。服务器在 Apache 后面的 Tomcat 上运行。默认情况下,Apache 和 Tomcat 都配置为使用 UTF-8 字符编码。我假设需要的是从 Android 应用程序发送到服务器的 http 请求都配备了一个包含“application/text; charset=utf-8”之类的标头。
我构建了这个精简的代码示例来说明这个问题。如您所见,我在设置标头的请求中包含了 addHeader()。我还在 RequestBody 上主动设置了一个字符集。
public static String testPost() throws IOException{
OkHttpClient okHttpClient = new OkHttpClient();
HttpUrl.Builder builder = new HttpUrl.Builder();
HttpUrl httpUrl = builder.scheme("https")
.host("dev.ourdomainname.com")
.addPathSegment("characterencoding")
.build();
Charset charset = Charset.forName(StandardCharsets.UTF_8.name());
RequestBody requestBody = new FormBody.Builder(charset)
.add("text", "xxåäöÅÄÖxx")
.build();
Request request = new Request.Builder()
.url(httpUrl)
.addHeader("Content-Type", "application/json; charset=utf-8") …Run Code Online (Sandbox Code Playgroud) 我遇到了MD5编码这个奇怪的问题.实际上,在每个人都跳进来告诉我不要使用MD5之前:它是一个遗留系统,并且已经选择了算法.
无论如何 - 我有一个存储MySQL了MD5哈希密码的表.在同一张表中,盐也被储存.
我有一个测试用户,密码是"test",盐是"salt".使用MySQLs MD5函数(select md5('testsalt')),我发现了哈希"315240c61218a4a861ec949166a85ef0".我还通过外部PHP系统的管理员验证了这一预期结果,该系统将用户信息发送到我们的系统.
在系统的一个模块中,我们MD5使用以下代码计算哈希值:
public static String md5EncryptString(String string, String salt) {
MessageDigest messageDigest;
String encryptString = string + salt;
String result;
try {
messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
messageDigest.update(encryptString.getBytes(Charset.forName("UTF8")));
final byte[] resultByte = messageDigest.digest();
result = new String(Hex.encodeHex(resultByte));
return result;
} catch (NoSuchAlgorithmException e) {
logger.error("NoSuchAlgorithmException in encryptString");
result = encryptString;
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
此方法输出完全相同的md5哈希值.
然后我在这个系统的Spring安全部分配置了一个Md5PasswordEncoder并遇到问题,因为它不会让我登录.通过扩展Md5PasswordEncoder类并使用一些日志记录覆盖encodePassword()方法,我能够确定它输出一个不同的md5哈希:"150671e7a5fb8ace58aaa012de7f9b5c"给出相同的密码 …
java ×4
android ×2
security ×2
spring ×2
spring-boot ×2
controller ×1
ipad ×1
iphone ×1
jackson ×1
javascript ×1
md5 ×1
okhttp ×1
rest ×1
utf-8 ×1