ssh界面传对象到controller-页面和controller代码

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/jsps/common/taglibs.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title></title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="<c:url value="/css/application.css"></c:url>">
    <link rel="stylesheet" type="text/css" href="<c:url value="/css/form.css"></c:url>">
    
     <style>
      .error{
        border:1px solid yellow;
        color:red;
        width:180px;
        padding:8px;
        margin:5px;
      }  
    </style>
    
  </head>
 
  <body>
    <s:actionerror cssClass="error" cssStyle="nowrap"/>
    <div id="wrapper">
        <div id="f_title">酒店房间登记</div>
        <s:form namespace="/room" action="createRoom" method="post">
            <div class="f_row">
              <span>房间房号:</span>
              <s:textfield name="room.roomNo"></s:textfield>
            </div>
            <div class="f_row">
              <span>所属分店:</span>
              <s:select name="room.hotel.hotelNo"
                        list="hotelList"
                        listKey="hotelNo"
                        listValue="hotelName"
                        headerKey="0"
                        headerValue="==请选择=="></s:select>
            </div>            
            <div class="f_row">
              <span>房间类型:</span>
              <s:radio name="room.roomType" list="#{'a':'普单人间','b':'普双人间','c':'三人间','d':'商务套房','e':'贵宾套房'}"></s:radio>
            </div>
            <div class="f_row">
              <span>屋内设施:</span>
              <s:checkboxlist name="room.roomEquip" list="#{\"a\":'平面液晶电视',\"b\":'冰箱',\"c\":'空调',\"d\":'卫星电视',\"e\":'互联网接入',\"f\":'冲浪浴缸',\"g\":'观海景'}"></s:checkboxlist>      
            </div>
            <div class="f_row">
              <span>房间状态:</span>
              <s:select name="room.roomStatus"
                        list="#{'a':'未入住','b':'有住客','c':'已预订','d':'保洁中','e':'已退房未保洁','f':'维护中'}"></s:select>          
            </div>
            <div class="f_row">
              <span>备注说明:</span>
              <s:textarea name="room.roomMemo" rows="8" cols="60"></s:textarea>
            </div>                                                    
            <div class="f_row">
              <s:submit value="保存信息"></s:submit>      
            </div>                                                                        
        </s:form> 
    </div>
  </body>
</html>


<pre name="code" class="java">package edu.fjnu.hotelsys.action;

import java.util.List;
import edu.fjnu.hotelsys.domain.Hotel;
import edu.fjnu.hotelsys.domain.Room;
import edu.fjnu.hotelsys.exception.ApplicationException;
import edu.fjnu.hotelsys.service.HotelService;
import edu.fjnu.hotelsys.service.HotelServiceImpl;
import edu.fjnu.hotelsys.service.RoomQueryHelper;
import edu.fjnu.hotelsys.service.RoomService;
import edu.fjnu.hotelsys.service.RoomServiceImpl;
import edu.fjnu.hotelsys.utils.Page;

/**
 * @author Administrator
 * 
 */
public class RoomAction extends BaseAction {

	private Room room;
	private RoomQueryHelper helper=null;
	private Page page=null;
	private List<Hotel> hotelList = null;	
	
	private HotelService hotelService=null;
	private RoomService roomService=null;
	
	
	
	public void setHotelService(HotelService hotelService) {
		this.hotelService = hotelService;
	}

	public void setRoomService(RoomService roomService) {
		this.roomService = roomService;
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	public RoomQueryHelper getHelper() {
		return helper;
	}

	public void setHelper(RoomQueryHelper helper) {
		this.helper = helper;
	}

	public List<Hotel> getHotelList() {
		return hotelList;
	}

	public void setHotelList(List<Hotel> hotelList) {
		this.hotelList = hotelList;
	}

	public Room getRoom() {
		return room;
	}

	public void setRoom(Room room) {
		this.room = room;
	}

	public String toInput() throws Exception {
		

		hotelList=hotelService.loadall();
		
		room=new Room();
		room.setRoomType("c");
		room.setRoomNo("1112");
		room.setRoomEquip(new String[]{"a","b","c"});
		
		return INPUT;
	}

	public String createRoom() throws Exception {
		
		try{
		   roomService.createRoom(room);
		}catch(ApplicationException e){
		   this.addActionError(e.getMessage());
			hotelList=hotelService.loadall();
		   return "input";
		}
		
		return "loadRoomsAction";
	}
	
	public String loadRooms() throws Exception{
		
		hotelList=hotelService.loadall();
		
		if(page==null) page=new Page();
		if(helper==null) helper=new RoomQueryHelper();
		
		page=roomService.loadPagedRooms(page, helper);
		
		return "list";
	}
	
	public String removeRoom() throws Exception{
		
		roomService.removeRoom(room.getRoomId());
		
	   return "loadRoomsAction";
	}
	
	public String preUpdate() throws Exception{

	   room=roomService.getRoomById(room.getRoomId());
	   hotelList=hotelService.loadall();	   
	   
	   return "update";
	   
	}
	
	public String updateRoom() throws Exception{
	   
	   try{
	    roomService.updateRoom(room);
	   }catch(ApplicationException e){
		   this.addActionError(e.getMessage());
		   hotelList=hotelService.loadall();	
		   return "update";
	   }
	   return "loadRoomsAction";
	}
}

 
 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值