0

I would like to add some data such as merchant name into database.I wanted it to be retrieved from a dropdownlist or combo box.For example,i added 7-eleven as merchant name into database,from another html page,a user can see "7 eleven" as an option to be selected in a dropdownlist.I don't use any jsp ,just HTML.Now what is successful is that I am able to add a merchant into database,but i don't really know how to pass the merchant name into dropdownlist.Any help would be appreciated!

This is my controller to add merchant

@RequestMapping(value = "/create", method = RequestMethod.POST)
public Object signUp(@ModelAttribute EmployeeSignUp employeeSignUp, HttpSession session, RedirectAttributes redirectAttributes) {
    try {
        employeeSignUp.setLoginId(employeeSignUp.getEmail());
        EmployeeDetail employee = employeeService.signUp(employeeSignUp);
        session.setAttribute("loginId", employeeSignUp.getLoginId());
        session.setAttribute("employeeId", employee.getId());

        return "redirect:/employeeSignin";

    } catch (Exception e) {
        return new ModelAndView("employee/create")
                .addObject("signUp", employeeSignUp)
                .addObject("error", e.getMessage());
    }
}

This is another controller that i wish to retrieve merchant name:

@RequestMapping(value = "/product", method = RequestMethod.GET)
public Object uploadProducts(@ModelAttribute UploadCreate uploadCreate,HttpSession session,RedirectAttributes redirectAttributes) {

 //   redirectAttributes.addFlashAttribute("list",employeeDetail.getName());
 //   redirectAttributes.addFlashAttribute("name",employeeDetail.getName());;

    return "product/upload";

}

This is the HTML page that I want merchant name to be retrieve from dropdownlist

 <form method="post" role="form" enctype="multipart/form-data">
            Merchant:
            <SELECT NAME="list" style=width:50%;" ID="list">
                <OPTION>Select a merchant</OPTION>
                {{#list}}
                <option>{{name}}</option>
                {{/list}}
            </SELECT>
6
  • why don't you use spring-mvc select tag for drop down list? Here is for your reference mkyong.com/spring-mvc/spring-mvc-dropdown-box-example
    – Ye Win
    Commented Nov 23, 2015 at 8:08
  • ya,i heard of this.But this is only available in jsp?what about html?or i just need to change the code style such as remove "form"
    – Ah Hiang
    Commented Nov 23, 2015 at 8:36
  • yeah, can't use in html file. But I think all html tag can use in jsp file and should advice to change html to jsp if you want to use spring mvc mainly.
    – Ye Win
    Commented Nov 23, 2015 at 8:41
  • For spring mvc, previous I mentioned mkyong.com website is quite great.
    – Ye Win
    Commented Nov 23, 2015 at 8:43
  • Thanks for your suggestion.Last question,If based on my condition,what i need is only add one additional jsp to pass it to the html output?
    – Ah Hiang
    Commented Nov 24, 2015 at 1:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.