http://example.com/path/to/page?name=ferret&color=purpleのような動的 URL を生成したい
ここで、名前と色の 2 つの個別の入力フィールドをフォームからコントローラーに単一のパラメーターとして送信できます。誰かが対応するjspとスプリングコントローラーのコーディングを手伝ってくれませんか。
以下は私のコントローラーです:
@RequestMapping(value = "/ws/jobs/{title}/{location}/{experience}")
public ModelAndView openRequirementsRedirect(JobSearchRequest jobSearchRequest) throws Exception{
ModelAndView model = new ModelAndView();
model.addObject("title", jobSearchRequest.getTitle());
model.addObject("location", jobSearchRequest.getLocation());
model.addObject("experience", jobSearchRequest.getExperience());
model.setViewName("openJobs/openjobs");
return model;
}
私はポジョを持っています:
public class JobSearchRequest {
private String title;
private String location;
private String experience;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getExperience() {
return experience;
}
public void setExperience(String experience) {
this.experience = experience;
}
}
y jsp 呼び出しは次のようなものです。
window.location.href = example+"/abc?&title="+title+"&location="+location+"&experience="+experience;