本文整理汇总了Java中com.opensymphony.xwork2.ActionContext类的典型用法代码示例。如果您正苦于以下问题:Java ActionContext类的具体用法?Java ActionContext怎么用?Java ActionContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionContext类属于com.opensymphony.xwork2包,在下文中一共展示了ActionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
@Override
public String execute() throws Exception {
String userName = (String)ActionContext.getContext().getSession().get("userName");
if(userName == null) {
errorMsg = "用户未登录!";
return ERROR;
}
try {
Controller.execute();
PushMail.PushUpdateMail(userName);
} catch(Exception e) {
errorMsg = "推送失败!";
return ERROR;
}
success = true;
return SUCCESS;
}
示例2: execute
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
@Override
public String execute() throws Exception {
String userName = (String)ActionContext.getContext().getSession().get("userName");
if(userName == null) {
errorMsg = "用户未登录!";
return ERROR;
}
try {
ContentHandler.testRemoveSomeRecords(userName, 5);
} catch (Exception e) {
errorMsg = "测试删除部分数据失败!";
return ERROR;
}
success = true;
return SUCCESS;
}
示例3: addUrl
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
public String addUrl() {
String userName = (String)ActionContext.getContext().getSession().get("userName");
try {
IUrlDAO urlDAO = UrlDAOFactory.getUrlDAOInstance();
urlID = urlDAO.doInsert(userName, title, url, true, realTimePush);
if(-1 == urlID) {
errorMsg = "添加记录失败!";
} else {
success = true;
return SUCCESS;
}
} catch (Exception e) {
errorMsg = "访问数据库出错!";
e.printStackTrace();
}
return ERROR;
}
示例4: toRoomManageFail
import com.opensymphony.xwork2.ActionContext; //导入依赖的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");
}
示例5: toRoomManage
import com.opensymphony.xwork2.ActionContext; //导入依赖的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";
}
示例6: execute
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
public String execute() throws Exception {
String res = "input";
Map<String, Object> session = ActionContext.getContext().getSession();
user = (User) session.get("webshop_user");
if(user != null && (user.getRole().getTyp().equals("admin"))) {
CategoryManager categoryManager = new CategoryManagerImpl();
// Add category
categoryManager.addCategory(newCatName);
// Go and get new Category list
this.setCategories(categoryManager.getCategories());
res = "success";
}
return res;
}
示例7: execute
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
public String execute() throws Exception {
String res = "input";
Map<String, Object> session = ActionContext.getContext().getSession();
user = (User) session.get("webshop_user");
boolean isAdmin = true;
if(user != null && isAdmin) {
CategoryManager categoryManager = new CategoryManagerImpl();
this.setCategories(categoryManager.getCategories());
if(pageToGoTo != null){
if(pageToGoTo.equals("c")){
res = "successC";
}
else if(pageToGoTo.equals("p")){
res = "successP";
}
}
}
return res;
}
示例8: execute
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
public String execute() throws Exception {
String result = "input";
Map<String, Object> session = ActionContext.getContext().getSession();
User user = (User) session.get("webshop_user");
if(user != null && (user.getRole().getTyp().equals("admin"))) {
ProductManager productManager = new ProductManagerImpl();
int productId = productManager.addProduct(name, Double.parseDouble(price), categoryId,
details);
if (productId > 0) {
result = "success";
}
}
return result;
}
示例9: execute
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
@Override
public String execute() throws Exception {
ActionContext actionContext = ActionContext.getContext();
int result = userManager.validLogin(getUser());
if (result == LOGIN_SUCCESS) {
ExpManager expManager = ExpManager.getInstance(userManager.getUserByAccount(user.getAccount()),
userManager);
if (!expManager.isLoginToday())
user = expManager.addExp(ExpManager.LOGIN);
user = userManager.updateLoginDate(userManager.getUserByAccount(user.getAccount()));
actionContext.getSession().put(WebConstant.USER, userManager.getUserBeanByAccount(user.getAccount()));
actionContext.getSession().put(WebConstant.AUTHORITY,
userManager.getAuthorityBeanByAccount(user.getAccount()));
actionContext.getSession().put(WebConstant.AUTHORITY_TABLE, userManager.getAllAuthorities());
return SUCCESS;
} else {
actionContext.getSession().put(WebConstant.INTERCEPT, "Wrong account or password");
return ERROR;
}
}
示例10: execute
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
@Override
public String execute() throws Exception {
ActionContext actionContext = ActionContext.getContext();
int result = userManager.validRegist(getUser());
if (result == REGIST_SUCCESS) {
ExpManager expManager = ExpManager.getInstance(userManager.getUserByAccount(user.getAccount()),
userManager);
if (!expManager.isLoginToday())
user = expManager.addExp(ExpManager.LOGIN);
user = userManager.updateLoginDate(userManager.getUserByAccount(user.getAccount()));
actionContext.getSession().put(WebConstant.VERIFY, user);
return SEND_MAIL;
} else {
actionContext.getSession().put(WebConstant.INTERCEPT, "Account is existed");
return ERROR;
}
}
示例11: execute
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
@Override
public String execute() throws Exception {
ActionContext actionContext = ActionContext.getContext();
User user = userManager.getUserByAccount(getOldAccount());
user.setPassword(getVerifyPassword());
int result = userManager.validLogin(user);
if (result == LOGIN_SUCCESS) {
user.setPassword(getVerifyPassword());
user = userManager.updateAccount(user, getNewAccount());
if (user != null) {
user = userManager.updateMailVerifyState(user, false);
actionContext.getSession().put(WebConstant.USER, userManager.getUserBeanByAccount(user.getAccount()));
actionContext.getSession().put(WebConstant.AUTHORITY,
userManager.getAuthorityBeanByAccount(user.getAccount()));
return SUCCESS;
} else {
actionContext.getSession().put(WebConstant.INTERCEPT_1, "Account is existed");
return ERROR;
}
} else {
actionContext.getSession().put(WebConstant.INTERCEPT_1, "Wrong Current Password");
return ERROR;
}
}
示例12: execute
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
@Override
public String execute() throws Exception {
ActionContext actionContext = ActionContext.getContext();
User user = userManager.getUserByAccount(getAccount());
user.setPassword(getOldPassword());
int result = userManager.validLogin(user);
if (result == LOGIN_SUCCESS) {
user = userManager.updatePassword(user, getNewPassword());
actionContext.getSession().put(WebConstant.USER, userManager.getUserBeanByAccount(user.getAccount()));
actionContext.getSession().put(WebConstant.AUTHORITY,
userManager.getAuthorityBeanByAccount(user.getAccount()));
return SUCCESS;
} else {
actionContext.getSession().put(WebConstant.INTERCEPT_2, "Wrong Current Password");
return ERROR;
}
}
示例13: loginInfo
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
public String loginInfo(){
MyUserDetails myUserDetails=(MyUserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
AcctUser user=accountManager.findUserByLoginName(myUserDetails.getUsername());
//��֤servlet session����ʱrole������
user.getRoleList();
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
session.put("user", user);
for(AcctRole role:user.getRoleList()){
/*if(role.getName().equals("����Ա")){
isAdmin=true;
System.out.println("\n\n����Ա��¼\n\n");
}*/
if(role.getId()==1){
session.put("isAdmin", true);
}
}
return "success_form";
}
示例14: addUser
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
public String addUser(){
String str =StringUtil.getfiletype(fileFileName);
user.setSelfpic("\\logo"+str);
userService.addUser(user);
User u = userService.login(user.getUsername(), user.getPassword());
String userFilename = PropertiesUtil.getFileProperties().getProperty("fileUrl")+u.getId();
String logoFileName = userFilename+"/logo"+str;
try
{
FileUtils.forceMkdir(new File(userFilename));
FileUtils.copyFile(file, new File(logoFileName));
System.out.println(u.getId()+"q123123123123");
String selfpic= "\\"+u.getId()+"\\logo"+str;
u.setSelfpic(selfpic);
u.setType(0);
userService.updata(u);
selfpic = PropertiesUtil.getFileProperties().getProperty("apacheUrl")+selfpic;
u.setSelfpic(selfpic);
ActionContext.getContext().getSession().put("u", u);
} catch (IOException e)
{
e.printStackTrace();
}
return "userPicture";
}
示例15: seeTestPaperUI
import com.opensymphony.xwork2.ActionContext; //导入依赖的package包/类
/** 查看习题 */
public String seeTestPaperUI() throws Exception{
//准备数据--单选列表
TestPaper testPaperFind=testPaperService.findById(testPaperId);
List<TestQuestion> testQuestionList=new ArrayList<>(testPaperFind.getTestQuestions());
List<Judgement> judgementList=new ArrayList<>();
for(int i=0;i<testQuestionList.size();i++){
if(testQuestionList.get(i).getJudgement()!=null){
judgementList.add(testQuestionList.get(i).getJudgement());
}
}
ActionContext.getContext().put("judgementList", judgementList);
//准备数据--单选
List<SingleChoice> singleChoiceList=new ArrayList<SingleChoice>();
for(int i=0;i<testQuestionList.size();i++){
if(testQuestionList.get(i).getSingleChoice()!=null){
singleChoiceList.add(testQuestionList.get(i).getSingleChoice());
}
}
ActionContext.getContext().put("singleChoiceList", singleChoiceList);
//准备--testPaperId
ActionContext.getContext().put("testPaperId", testPaperId);
return "seeTestPaperUI";
}