令牌“,”上的语法错误,此令牌后预期的标识符

时间:2014-01-24 21:45:30

标签: java android syntax syntax-error

我收到一个日食错误说明:

Syntax error on token ",", Identifier expected after this token

就行:

@Element(name="Video", =false)

之前有没有遇到过这个?我做了一个google和SO搜索,我无法想出多少。

来源:

public class Post extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.testparse);
         @Element(name="Title",required=false)
            String title;

            @Element(name="Video", =false)
            String video;

    }
    private void doParse()
    {
                // static body here, but you can pass a Stream to the serializer too
        String xmlBody = "<response><cmd>getPosts</cmd><success>1</success><NumberOfSongs>4</NumberOfSongs><Posts><Post><Title>Stream</Title><Video/></Post><Post><Title>Movies</Title><Video/></Post><Post><Title>Music</Title><Video/></Post><Post><Title>Hello world!</Title><Video/></Post></Posts></response>";

        Serializer serializer = new Persister();
        PostResponse response = null;
        try {
            response = serializer.read(PostResponse.class, xmlBody);
        } catch (Exception e) {
            e.printStackTrace();
        }

        // something interesting with the classes now

    }
} 

1 个答案:

答案 0 :(得分:2)

我的朋友,你有一个语法错误,错过了该值的键: 你在写:

@Element(name="Video", =false)

你错过了“必需的”

@Element(name="Title",required=false)