在处理基于UDP的java项目时,我遇到了一个非常奇怪的问题。总结一下,当我通过DataPacket收到请求时,我将其转换为新的字符串,然后当我去检查字符串值时,它继续返回false。代码如下。
<ion-side-menus>
<ion-side-menu side="left">
<!--**** This works**** -->
<ion-header-bar ng-class="myvar">
<h1 class="title">Menu</h1>
</ion-header-bar>
<ion-content>
<ion-list>
...
</ion-list>
</ion-content>
</ion-side-menu>
<ion-side-menu-content>
<!--**** This doesn't work**** -->
<ion-nav-bar ng-class="myvar" >
<!--**** If i change it for class={{myvar}}, it doesn't refresh**** -->
...
</ion-nav-bar>
<ion-nav-view name="menuContent"></ion-nav-view>
</ion-side-menu-content>
</ion-side-menus>
答案 0 :(得分:1)
尝试修剪你的信息,也许它包含空格。
DatagramPacket request = new DatagramPacket(buffer, buffer.length);
aSocket.receive(request);
String message = new String(request.getData()).trim();
System.out.println("Received: " + new String(request.getData()));
System.out.println(message); //Prints out "11" without quotes when I send it
String a = "11";
System.out.println("Received: " + message);
if(message.equals("11")){
System.out.println("Got 11.");
}