小编hel*_*igo的帖子

从右到左支持百分号

假设有一段代码如下:

<div dir="rtl">
  test 50%
</div>
Run Code Online (Sandbox Code Playgroud)

它呈现为test 50%. 但根据这个阿拉伯语维基页面,%50 test它应该显示为. 请注意,百分号位于数字之前。问题如下:如何强制执行所需的行为?浏览器支持 OOB 吗?有已知的方法可以轻松做到这一点吗?

联合发展署。我将提供更多背景信息。有一个带有输入文本属性的角度分量。假设它可能如下所示:

<component [label]="'test 50%'"></component>
Run Code Online (Sandbox Code Playgroud)

那么它的模板如下所示:

<span>{{label}}</span>
Run Code Online (Sandbox Code Playgroud)

它适用于从左到右的模式。但是,当启用从右到左模式时,文本会向右对齐,但浏览器不会修改文本。我之所以认为可能会被浏览器自动修改,是因为下面的文字test this!被修改为:!test this自动被浏览器修改。

我是否需要修改组件以便它接受已经 RTL 修改的文本?

html right-to-left angular

5
推荐指数
1
解决办法
422
查看次数

小程序.java.lang.reflect.InvocationTargetException

我有applet使用jna Pointer类.小程序代码是:

import com.sun.jna.*;
public class Applet1 extends Applet{
    public void test() {
        try {
            Pointer p = new Memory(73);
        } catch (Exception e) {
        e.printStackTrace();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在html代码中,我以这种方式声明了applet:

<applet
    codebase=/pki/
    code=Applet1.class 
    archive=/pki/jna-3.2.3.jar
    id=Applet1
    width=100 
    height=100 >
</applet>
Run Code Online (Sandbox Code Playgroud)

当我通过javascript调用document.getElementById("Applet1").test()时,会出现java.lang.reflect.InvocationTargetException.我不能在java类中调用e.getCause(),因为applet try/catch不会捕获错误(我不明白为什么).但javascript try/catch捕获此错误.如果移动Pointer p = new Memory(73);线就可以了.问题是这一行.请帮助解决问题.

编辑:如果替换此块:

try {
    Pointer p = new Memory(73);
} catch (Exception e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

try {
    Pointer p = new Memory(73);
} catch (Throwable e) {
    System.out.println(e.getCause());
}
Run Code Online (Sandbox Code Playgroud)

我得到java.security.AccessControlException:访问被拒绝(java.util.PropertyPermission jna.boot.library.path …

java applet exception

4
推荐指数
1
解决办法
6900
查看次数

使用JNI的Java代码流

我有JNI级别的代码.它可以抛出异常.代码是:

#include "JavaGlueClass.h"
#include <stdio.h>         
#include <windows.h>
#include <string.h>

jint throwNoClassDefError(JNIEnv *env, const char *message)
{
    jclass exClass;
    char *className = (char *) "java/lang/NoClassDefFoundError" ;

    exClass = env->FindClass(className);

    if ( exClass != NULL ) {
        return env->ThrowNew(exClass, message);
    }

    //free the local ref 
    env->DeleteLocalRef(exClass);

}

void throwGetFieldIDException(JNIEnv *env)
{
    const char *className = "GetFieldIDException";
    jclass exClass = env->FindClass(className);
    if (exClass == NULL) {
        throwNoClassDefError(env, className);
    } else {
        env->ThrowNew(exClass, "GetFieldIDException message");
    }
    env->DeleteLocalRef(exClass);
    printf("printprint");
}




JNIEXPORT jobject JNICALL Java_JavaGlueClass_test(JNIEnv *env, …
Run Code Online (Sandbox Code Playgroud)

java java-native-interface exception

3
推荐指数
1
解决办法
1895
查看次数

编写注释意味着在Java中"无所事事"的常见做法是什么?

我有下一个代码:

InputStream is = new FileInputStream("test.txt");
// do something
try {
    is.close();
} catch(IOException ex) {
    // do nothing
    // or
    // NOP
    // or something else?
}
Run Code Online (Sandbox Code Playgroud)

问题是Java世界中是否有任何约定可以告诉您什么都不做?就像在我的情况下,如果无法关闭InputStream,我想什么都不做."NOP"评论是否可以接受?它来自Assembler,意思是"无操作".

java comments exception

2
推荐指数
1
解决办法
437
查看次数

如何在C中获取struct字段

我有代码:

main() 
{
   typedef struct
   {
      int data;
   } Information;

   typedef Information *PtrInformation;

   typedef struct InformationListStruct *PtrInformationListStruct;

   typedef struct InformationListStruct
   {
      PtrInformationListStruct ptrNext;
      PtrInformation ptrInf;
   } PtrInformationListStructElement;

   //==============================

   PtrInformationListStruct list;
   list = (PtrInformationListStruct)malloc(sizeof(InformationListStruct));
   PtrInformation ptr = (*list).ptrInf;  // error !!!

}
Run Code Online (Sandbox Code Playgroud)

编译器抛出错误:

  • "ptrInf"不是InformationListStruct的成员,因为函数main()中尚未定义类型

如果我把这一行:

typedef struct InformationListStruct *PtrInformationListStruct;
Run Code Online (Sandbox Code Playgroud)

在这之后:

   typedef struct InformationListStruct
   {
      PtrInformationListStruct ptrNext;
      PtrInformation ptrInf;
   } PtrInformationListStructElement;
Run Code Online (Sandbox Code Playgroud)

然后出现其他错误:

  • 函数main()中预期的类型名称
  • 宣言缺失; 在函数main()中

如何正确获得"ptrInf"?

c struct

1
推荐指数
1
解决办法
245
查看次数