日期:2014-05-17  浏览次数:20753 次

jsp中的switch问题!
部分代码:
String xmlb=rs.getString("xmlb");
switch(xmlb){
  case "BHJS" :  
  xmztmessage="项目驳回结束"; 
  case "UTOG" :
  xmztmessage="用户向管理员申请,待管理员审核";
  case "YSCTOG" :  
  xmztmessage="厂家预算提交管理员审核";……………………
问题:Sting的switch不能用,如何把String转换成char。case比较多,有什么好的方法请大家多多指教!

------解决方案--------------------
jdk1.7 switch支持 String类型。。
------解决方案--------------------
HashMap<String,Integer> map = new HashMa<String,Integer>();
map.put("BHJS",1);
map.put("UTOG",2);
map.put("YSCTOG",3);
String xmlb=rs.getString("xmlb");
int i = map.get(xmlb);
switch(i){
case 1 :
xmztmessage="项目驳回结束"; 
case 2 :
xmztmessage="用户向管理员申请,待管理员审核";
case 3 :
xmztmessage="厂家预算提交管理员审核";……………………
------解决方案--------------------
java7支持的。