0
public String searchUserById(@RequestParam(value = "fileType", required = true) String fileType) {
    System.out.println(fileType);
    return "downloadexcel";
}

public String searchUserByName(@RequestParam(value = "fileType", required = true) String fileType, @RequestParam(value = "batchNo", required = true) String batchNo) {
    System.out.println(fileType + " ----------- " + batchNo);
    return "downloadexcel";
}

This kind of URL Patterns i need I found some relevant Questions but i am getting 400 bad request when hitting the url

1.http://localhost:8080/apna-shopee/download.htm?fileType=mani 2.http://localhost:8080/apna-shopee/download.htm?fileType=mani&batchNo=1001

Didn't find the correct solution.

halfer
  • 19,824
  • 17
  • 99
  • 186
Manikanta Reddy
  • 849
  • 9
  • 23
  • 1
    Hi, I think you could manage both requests in the same method in your controller if you set required = false for batchNo parameter. In this case you should check the value of batchNo in your controller (if its null, it wasn't in the URL) – Igorovics Sep 15 '15 at 06:39
  • That is what i am doing now., see the below question comment. but i am learning spring with this application so please help me out., if you know about parameter passing.,Thanks – Manikanta Reddy Sep 15 '15 at 06:46
  • Which solution would you like to use? One method which can handle both cases, or two different methods for the two cases? Another question: did you add the @RequestMapping annotation to your methods? – Igorovics Sep 15 '15 at 08:29
  • In class level I have added @RequestMapping – Manikanta Reddy Sep 15 '15 at 11:39

1 Answers1

0

visit following link this may help you to solve your issue create two method for same url pattern with different arguments

You can also do this based on condition. just make simple method with two parameters and based on second parameter value you can perform appropriate action. i.e if second parameter value is null that means request done using only single parameter

Community
  • 1
  • 1
Krupesh Kotecha
  • 2,396
  • 3
  • 21
  • 40