开发者

Trying to do searchable username from query result

I'm using google app engine to do a website that has some messages, i would like to display the message with a name in form of a link that appointed to the person profile. The only problem is that all my webpages are dynamic and printed from the code.

What I first thought of doing was a link that in click it would call a method in the program with the parameter of the clicked name. The method would then receive the 开发者_如何学运维paramet of the name, do a query and print the profile in a new webpage. I think this would work fine. The problem and question i have is how do I do the clickable name with method call.

My code to print the text message to the html page now is:

  List<Texto> results = (List<Texto>) query.execute(tituloparam);

    if (!results.isEmpty()) 
    {
        for (Texto e : results) 
        {
            resp.getWriter().println("Titulo:"
                + results.get(0).titulo);
            resp.getWriter().println("Nome:<a href='/author?name=" + results.get(0).autor + "'>" + results.get(0).autor + "</a>");
            resp.getWriter().println("Data:"
                + results.get(0).data);
            resp.getWriter().println("Texto:"
                + results.get(0).texto);
        }
    }

So the autor would be the clickable object. Can anyone help me?

Edit 1: Thanks to uwe (Thank you) now I have a clickable object. But how do I call a method with the parameter = autor from there?


You need to add a link to it like this:

 resp.getWriter().println("Nome:<a href='/author?name=" + results.get(0).autor + "'>" + results.get(0).autor + "</a>");

Then it shows it as link and makes it clickable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜