0

Here is my HTML Page :

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sports</title>
</head>
<body>
    <center>
        <h1>Configuring Database for MSell Application</h1>
        <form method="post" action="http://localhost:8080/MSellApp/msellapp/DBConfig/changedb" enctype="text/plain">
            <table border="0">
                <tr>
                    <td>Database to be Used</td>
                    <td><select name="selectDB">
                            <option value=0>Sports and Outdoor</option>
                            <option value=1>Fashion</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="2"><input type="submit" value="submit"></td>
                </tr>
            </table>
        </form>
    </center>
</body>
</html>

Here is my spring rest service.

@RequestMapping("/DBConfig")
@RestController
public class DBConfigController {

    final static Logger logger = Logger.getLogger(DBConfigController.class);


    @Autowired
    DBConfig dbc;

    @RequestMapping(value="/changedb",method = RequestMethod.POST,consumes="text/plain",produces="text/plain")
    String changeDB(@RequestBody String db){
        logger.info("DB Selected :- " +db);
        System.out.println(db);

            if(db.equals("selectDB=0"))
                dbc.sessionFac="sports";
            else
                dbc.sessionFac="fashion";


        return dbc.sessionFac;


    }
}

That String comparison is always getting failed.I am using spring rest API. I'm just finding it too difficult to crack why the string comparison always fails even though the print statement prints the same "selectDB=0". Can Somebody tell me why ?

KarthickN
  • 335
  • 1
  • 6
  • 20

0 Answers0