本文整理汇总了Java中org.apache.struts2.convention.annotation.Action类的典型用法代码示例。如果您正苦于以下问题:Java Action类的具体用法?Java Action怎么用?Java Action使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Action类属于org.apache.struts2.convention.annotation包,在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toFifth
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value = "toFifth", results = { @Result(name = "stepFifthUI", location = ViewLocation.View_ROOT
+ "orderstep4.jsp") })
public String toFifth() throws Exception{
//未支付押金订单生成
Mrcodeorder order = null;
if((order=createOrder())!=null){
for(Password p : order.getPasswords()){
String msg = "【码团网】"+p.getContactors().getName()+"您好!您已下单成功,日期:"+p.getEstimatedTime().toString().substring(0,10)+
",房间:"+p.getRoom().getRoomNumber()+"。酒店正为您办理入住手续,至酒店确认本人身份后,凭房间密码"+p.getPassword()+"即可入住。";
System.out.println("message:"+msg);
JSONObject o = JSONObject.fromObject(MessageSend.sendSms(msg, p.getContactors().getPhoneNumber()));
System.out.println("result:"+o);
}
request.setAttribute("msg", "已完成房间入住手续,请至酒店前台核对身份证,并支付押金,即可入住,谢谢!");
}
return "stepFifthUI";
}
示例2: update
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value = "department.update",
results = {@Result(name = "detail", location="department-detail.jsp")}
)
public String update() {
//ok, it might sound a bit redundant, but if we change the
//persistence mechanism to a database, all these
//lines would be necessary.
Department old = CompanyService.instance().findDepartment(department.getId());
old.setName(department.getName());
old.setManager(department.getManager());
department = old;
message = "The department data was updated.";
return "detail";
}
示例3: execute
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@SkipValidation
@Override
@Action(value = "wxlogin")
public String execute() {
logger.debug("execute normally end.");
String backUri =this.getDomain()+"/getopenid";
backUri+="?forwardUrl="+forwardUrl;
String url;
try {
url = WeixinUtils.buildOAuthUrl(backUri);
this.setForwardUrl(url);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return GOTO_REDIRECT;
}
示例4: execute
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@SkipValidation
@Override
@Action(value = "wxregister")
public String execute() {
logger.debug("execute normally end.");
String backUri =this.getDomain()+"/wxregisteruser";
backUri+="?forwardUrl="+forwardUrl;
String url;
try {
url = WeixinUtils.buildOAuthUserInfoUrl(backUri);
this.setForwardUrl(url);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return GOTO_REDIRECT;
}
示例5: execute
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@SkipValidation
@Override
@Action(value = "paycallback")
public String execute() {
logger.debug("execute normally end.");
try {
Thread.sleep(1000);
TUser user = new TUser();
//修改金额
user = userService.getByNo(LoginManager.getLoginUser().getUserno());
// 登录处理
LoginManager.doLogin(user);
HttpSession session = LoginManager.getSession(false);
if (Utils.isDefined(session)) {
String forwardUrl =(String)session.getAttribute("paypreurl");
this.setForwardUrl(forwardUrl);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return GOTO_REDIRECT;
}
示例6: toRoomManageFail
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value = "toRoomManageFail")
public void toRoomManageFail() throws Exception{
if(ActionContext.getContext().get("msg")!=null)
request.setAttribute("msg", ActionContext.getContext().get("msg"));
Customer cus = (Customer) session.get("customer");
String phoneNumber = cus.getPhoneNumber();
System.out.println("phoneNumber--" + phoneNumber );
//1、先根据该用户电话号码得到,password对象
Password passwd = passwordService.getPasswordByPhone (phoneNumber);
if(passwd == null) {
// 代表无可用房间
writeStringToResponse("1");
} else
writeStringToResponse("0");
}
示例7: toRoomManage
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value = "toRoomManage", results = { @Result(name = "toRoomManage", location = ViewLocation.View_ROOT
+ "management.jsp") })
public String toRoomManage() throws Exception{
if(ActionContext.getContext().get("msg")!=null)
request.setAttribute("msg", ActionContext.getContext().get("msg"));
Customer cus = (Customer) session.get("customer");
String phoneNumber = cus.getPhoneNumber();
System.out.println("phoneNumber--" + phoneNumber );
//1、先根据该用户电话号码得到,password对象
Password passwd = passwordService.getPasswordByPhone (phoneNumber);
// if(passwd == null) {
//
// writeStringToResponse("1");
// }
System.out.println("输出Password id--" + passwd.getId());
//2、根据该password对象,得到roomId
Room room = passwd.getRoom();
System.out.println(room.getId());
// 懒加载:System.out.println("获取hotel--" + room.getRoomtype().getHotel().getName());
//3、根据roomId 获取房间类型
//RoomType roomtype = roomService.getRoomTypeByRoomId();
request.setAttribute("customer", cus);
request.setAttribute("roomid", room.getId());
request.setAttribute("roomnumber", room.getRoomNumber());
return "toRoomManage";
}
示例8: sendVerification
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
/**
* 发送短信验证码
*
* @return
*/
@Action(value = "sendVerification")
public void sendVerification() throws Exception {
String phone = getParameter("phone");
System.out.println("CustomerAction.sendVerification()");
// 1.生成验证码
String verificationCode = MessageSend.getVerificationCode();
try {
JSONObject result = JSONObject
.fromObject(MessageSend.sendDynamicVerification(
verificationCode, phone));
if ("OK".equals(result.get("msg"))) {
session.clear();
session.put("verificationCode", verificationCode);
writeStringToResponse("【ok】");
}
} catch (Exception e) {
log.error("发送验证码失败!");
e.printStackTrace();
}
}
示例9: toFirst
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value = "toFirst", results = { @Result(name = "stepFirstUI", location = ViewLocation.View_ROOT
+ "orderstep0.jsp") })
public String toFirst() throws Exception{
//跳转至入住第一步,选择日期页面
Customer customer = (Customer)session.get(Const.CUSTOMER);
//获得房间类型
Integer typeId = getIntParameter("typeId", -1);
Integer validCount = grouppurchasevoucherService.getTypeCount(customer, typeId);
dataMap.put("id", typeId);
Roomtype roomtype = roomtypeService.findUniqueByHql("from Roomtype r left join fetch r.hotel where r.id=:id", dataMap);
session.put("roomtype", roomtype); //选择的房间类型
session.put("validCount", validCount); //团购券数量
return "stepFirstUI";
}
示例10: toThird
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value = "toThird", results = { @Result(name = "stepThirdUI", location = ViewLocation.View_ROOT
+ "orderstep2.jsp") })
public String toThird() throws Exception{
//TODO 跳转至第三步,订单展示及确认页面
Customer customer = (Customer)session.get(Const.CUSTOMER);
String ids = getParameter("ids");
List<Room> rooms = roomService.getByIds(ids);
List<Contactors> contactors = contactorsService.getContactorsByCustomerId(customer);
Integer days = (Integer)session.get("days");
Roomtype roomtype = (Roomtype)session.get("roomtype");
//需要使用的团购券,放入session
Integer needVouchers = days*rooms.size();
pageBean.setPageSize(needVouchers);
List<Grouppurchasevoucher> vouchers = grouppurchasevoucherService.getByType(customer, roomtype, pageBean);
session.put("vouchers", vouchers);
request.setAttribute("total", needVouchers*vouchers.get(0).getPrice());
session.put("rooms", rooms);
request.setAttribute("contactors", contactors);
return "stepThirdUI";
}
示例11: addContactor
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value = "addContactor")
public void addContactor(){
//TODO 添加联系人,成功返回 1,失败返回0
try {
Customer customer = (Customer)session.get(Const.CUSTOMER);
String userName = getParameter("name");
String phoneNumber = getParameter("phone");
String identityCard = getParameter("idCard");
if (contactorsService.isExist(identityCard, customer)) {
writeStringToResponse("0");
return ;
}
Contactors cont = new Contactors();
cont.setCustomer(customer);
cont.setIdentityCard(identityCard);
cont.setName(userName);
cont.setPhoneNumber(phoneNumber);
cont.setIsSelf(0);
Integer id = contactorsService.save(cont);
writeStringToResponse(id.toString());
} catch (Exception e) {
// TODO: handle exception
writeStringToResponse("0");
}
}
示例12: toOrder
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value="toOrder", results={@Result(name="orderUI", location=ViewLocation.View_ROOT+
"hotel.jsp")})
public String toOrder() throws Exception{
//TODO 跳转到选择团购券的页面
Customer customer = (Customer)session.get(Const.CUSTOMER);
List<Grouppurchasevoucher> gps = grouppurchasevoucherService.getByCust(customer);
//把数据封装成Map
Map<Roomtype, List<Grouppurchasevoucher>> rgMap = new LinkedHashMap<Roomtype, List<Grouppurchasevoucher>>();
for(Grouppurchasevoucher gp : gps){
if(!rgMap.containsKey(gp.getRoomtype())){
List<Grouppurchasevoucher> grps = new LinkedList<Grouppurchasevoucher>();
rgMap.put(gp.getRoomtype(), grps);
}
rgMap.get(gp.getRoomtype()).add(gp);
}
request.setAttribute("rgMap", rgMap);
return "orderUI";
}
示例13: updateRoomTypeInfo
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value="updateRoomTypeInfo")
public void updateRoomTypeInfo() throws Exception{
String roomJson=(String) request.getParameter("json").trim();
JSONObject jsonObject = JSONObject.fromObject(roomJson);
String typeId = jsonObject.getString("rcName");
String typeName = jsonObject.getString("rcBedNumber");
String priceString = jsonObject.getString("rcPrePrice");
String discountString = jsonObject.getString("rcPreDiscount");
priceString=priceString.trim();
discountString=discountString.trim();
Float price=Float.parseFloat(priceString);
Float discount=Float.parseFloat(discountString);
Roomtype roomtype = roomtypeService.findRoomtypeByTypeId(1, typeId);
Hotel hotel = hotelService.getById(1);
System.out.println();
if(roomtype==null){
roomtype = new Roomtype();
roomtype.setTypeName(typeName);
roomtype.setTypeId(typeId);
roomtype.setPrice(price);
roomtype.setDiscount(discount);
roomtype.setHotel(hotel);
roomtypeService.save(roomtype);
}
else{
roomtype.setTypeName(typeName);
roomtype.setTypeId(typeId);
roomtype.setPrice(price);
roomtype.setDiscount(discount);
roomtype.setHotel(hotel);
roomtypeService.update(roomtype);
}
response.getWriter().write("{success:true}");
return;
}
示例14: anno4
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action(value = "anno4", interceptorRefs = @InterceptorRef("auth"), results = {
@Result(type = "stream", params = { "inputName", "inputStream", "contentDisposition",
"attachment;filename=\"${downloadFileName}\"", "bufferSize", "512" }) }, params = {})
// @Action(value = "anno4")
public void anno4() throws IOException {
ServletActionContext.getResponse().setContentType("text/html;charset=utf-8");
PrintWriter out = ServletActionContext.getResponse().getWriter();
try {
out.print("TestStruts2ActionAnno4 anno4()");
out.flush();
out.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
示例15: getAllGames
import org.apache.struts2.convention.annotation.Action; //导入依赖的package包/类
@Action("getAllGames")
public void getAllGames(){
try{
int count = this.gameManager.getGameCount();
List<UGame> lst = this.gameManager.queryPage(page, rows);
JSONObject json = new JSONObject();
json.put("total", count);
JSONArray masterArray = new JSONArray();
for(UGame m : lst){
masterArray.add(m.toJSON());
}
json.put("rows", masterArray);
renderJson(json.toString());
}catch(Exception e){
e.printStackTrace();
}
}