Mybatis裡面:
select
from AUS_USERS
where 1 = 1
and AUS_CARDCODE LIKE CONCAT(CONCAT('%','#{ausCardcode}','%'))
<if test="ausUsername != null">
and AUS_CARDCODE LIKE CONCAT(CONCAT('%','#{ausUsername}','%') )
</if>
接口:
/** String ausCardcode, String ausUsername
* 根據賬號,姓名查詢
* @param ausCardcode
* @param ausUsername
* @return
*/
List allUser(Map map);
Controller裡面:
@RequestMapping("userInfo")
public String userInfo(HttpServletRequest request,
HttpServletResponse response,Map map) throws IOException {
map.get("ausCardcode");
map.get("ausUsername");
List<AusUsers> ausUser=ausUsersMapper.allUser(map);
request.setAttribute("AusUser", ausUser);
return "system/userInfo";
}
Jsp:
<li>賬號:<input type="text" name="ausCardcode" size="10" maxlength="30" /></li>
<li>姓名:<input type="text" name="ausUsername" size="10" maxlength="30" /></li>
</ul>
<input type="submit" name="button" value="查詢" class="btn btn-success">
為什麼獲取不到name="ausCardcode"和 name="ausUsername"這兩個參數的值?
用request.getparameter("ausCardcode")試試看