我有这个简单的控制器
@Controller
@RequestMapping("/login")
public class LoginController {
private ModelAndView model;
@RequestMapping(value="/loginUser/{username}/{password}", method=RequestMethod.GET)
public ModelAndView loginUser(@PathVariable(value="username") String username, @PathVariable(value="password") String password) {
try {
if( checkCredential( username , password ) ) {
model = new LoginResult( "loginOK" );
model.addObject( "msg" , username );
} else {
model = new LoginResult( "loginKO" );
model.addObject( "msg" , "Impossible to login the user " + username );
}
} catch(Exception e) {
e.printStackTrace();
}
return model;
}
}

和这个简单的JSP来执行登录
<form method="get" action="/login/loginUser">
<div class="div-top-end-space"> </div>
<div>
<label class="form-label"><i class="fa fa-chevron-right fa-1"></i> USERNAME:</label>
<input class="form-input" type="text" name="username" ng-model="username" />
</div>
<div>
<label class="form-label"><i class="fa fa-chevron-right fa-1"></i> PASSWORD:</label>
<input class="form-input" type="password" name="password" ng-model="password" />
</div>
<div class="div-separator"></div>
<div>
<input type="submit" value="LOGIN" ng-disabled="checkCredential()"/>
</div>
<div class="div-top-end-space"> </div>
</form>
&#13;
此代码正常运行,但我必须加入URL http://localhost:9001/MY_APP/login/loginUser/aaa/bbb
但我不希望用户名和密码显示在浏览器的URL中。 所以我将方法更改为方法=&#34; post&#34;并且进入控制器,方法=&#34; RequestMethod.POST&#34;。 当我运行我的应用程序并插入我的用户名和密码时,它不起作用,并且我在URL中看到了这个
http://localhost:9001/login/loginUser
感谢大家。
丹尼尔。