开发者

Get param from html to java function call

I am working with a java generated dynamic webpage, and I'm printing links from a query to a JDO. But I don't understand how can I get 开发者_开发问答and use the parameter from the url.

My html objects are printed like this

 print = print + "Nome:<a href='displayFotos?album="+results.get(i).nome+ "'>"+ 
 results.get(i).nome+ "</a></br>";

The results in having for example:

Nome:<a href='displayFotos?album=album1'>album1</a>

So, in my head when clicked it should be calling the address of the dynamic webpage album like this and should get the parameter. In this case it would be the album1.

  else if (address.indexOf("/dinamicas/album") != -1)   {
        String album = param1;
        System.out.println("did it work? "+album);
    }

And I have in the beginning of the class a general parameter that I use to get text from html forms.

  String param1 = req.getParameter("param1");

I understand this might be an easy question but I'm not getting there by myself.


 Nome:<a href='displayFotos?album=album1'>album1</a>

Here, you're using a parameter name of album.

However, you're attempting to get it by a parameter name of param1. This does obviously not match.

 String param1 = req.getParameter("param1");

You need to use the same parameter name as is been definied in the request.

String album = req.getParameter("album");
// ...
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜