本文整理匯總了Java中com.opensymphony.xwork2.ActionContext.getSession方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionContext.getSession方法的具體用法?Java ActionContext.getSession怎麽用?Java ActionContext.getSession使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.opensymphony.xwork2.ActionContext的用法示例。
在下文中一共展示了ActionContext.getSession方法的21個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: createExtraContext
點讚 3
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
protected Map createExtraContext() {
Map newParams = createParametersForContext();
ActionContext ctx = new ActionContext(stack.getContext());
PageContext pageContext = (PageContext) ctx.get(ServletActionContext.PAGE_CONTEXT);
Map session = ctx.getSession();
Map application = ctx.getApplication();
Dispatcher du = Dispatcher.getInstance();
Map extraContext = du.createContextMap(new RequestMap(req),
newParams,
session,
application,
req,
res);
ValueStack newStack = valueStackFactory.createValueStack(stack);
extraContext.put(ActionContext.VALUE_STACK, newStack);
// add page context, such that ServletDispatcherResult will do an include
extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext);
return extraContext;
}
開發者ID:txazo,項目名稱:struts2,代碼行數:25,
示例2: createNewTopic
點讚 3
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String createNewTopic(){
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
AcctUser user=(AcctUser)session.get("user");
if(user==null){
return "login";
}
List filters = new ArrayList();
PropertyFilter filter = new PropertyFilter("EQL_section.id", SECTIONID);
filters.add(filter);
nodes = bbsManager.findAllNodesByFitler(filters);
for(Node n:nodes){
System.out.println(n.getName());
}
return "createNewTopic";
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:22,
示例3: doIntercept
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
ActionContext actionContext = invocation.getInvocationContext();
Map session = actionContext.getSession();
Admin admin = (Admin) session.get("admin");
if (admin != null) {
return invocation.invoke();
}
actionContext.put("notice", "您還未登錄,無法獲得管理員權限");
return Action.LOGIN;
}
開發者ID:RyougiChan,項目名稱:NewsSystem,代碼行數:15,
示例4: intercept
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
@Override
public String intercept(ActionInvocation invocation) throws Exception {
// ��ȡActionContext
ActionContext context = invocation.getInvocationContext();
// ��ȡMap���͵�session
Map session = context.getSession();
// �ж��û��Ƿ��¼
if(session.get("admin") != null){
// ����ִ�з���
return invocation.invoke();
}
// ���ص�¼
return BaseAction.USER_LOGIN;
}
開發者ID:java-scott,項目名稱:java-project,代碼行數:15,
示例5: intercept
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext context = invocation.getInvocationContext();// ��ȡActionContext
Map session = context.getSession();// ��ȡMap���͵�session
if(session.get("customer") != null){// �ж��û��Ƿ��¼
return invocation.invoke();// ����ִ�з���
}
return BaseAction.CUSTOMER_LOGIN;// ���ص�¼
}
開發者ID:java-scott,項目名稱:java-project,代碼行數:10,
示例6: intercept
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String intercept(ActionInvocation invocation) throws Exception {
LOG.debug("Clearing HttpSession");
ActionContext ac = invocation.getInvocationContext();
Map session = ac.getSession();
if (null != session) {
session.clear();
}
return invocation.invoke();
}
開發者ID:txazo,項目名稱:struts2,代碼行數:12,
示例7: resolveModel
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
protected Object resolveModel(ObjectFactory factory, ActionContext actionContext, String modelClassName, String modelScope, String modelName) throws Exception {
Object model;
Map scopeMap = actionContext.getContextMap();
if ("session".equals(modelScope)) {
scopeMap = actionContext.getSession();
}
model = scopeMap.get(modelName);
if (model == null) {
model = factory.buildBean(modelClassName, null);
scopeMap.put(modelName, model);
}
return model;
}
開發者ID:txazo,項目名稱:struts2,代碼行數:15,
示例8: updateAndDelete
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
@Override
public void updateAndDelete(int id) {
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
String select=(String) session.get("select");
String message=(String) session.get("message");
Connection conn=null;
String sql=null;
if(!message.equals("")){
if(select.equals("id")){
try{
conn=getConnection();
sql="UPDATE `scada`.`meet_room` SET `useful`='����' WHERE `meetroom_id`="+"'"+id+"'";
PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
ps.executeUpdate();
//MeetManager meetManager=(MeetManager)this.getSessionFactory().openSession().get(MeetManager.class, id);
//this.getHibernateTemplate().delete(meetManager);
//this.getSessionFactory().openSession().close();
conn.close();
conn=null;
System.out.println(conn);
}catch(Exception e){
System.out.println(e);
}
}
}
}
開發者ID:bjut-2014,項目名稱:scada,代碼行數:40,
示例9: delete
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
@Override
public void delete(String mess){
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
String select=(String) session.get("select");
String message=(String) session.get("message");
int id =Integer.valueOf(mess);
/*
Connection conn=null;
String sql=null;
try{
conn=getConnection();
sql="DELETE FROM `big_project`.`meet_manager` WHERE `meet_id`="+"'"+id+"'";
PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
ps.executeUpdate();
conn.close();
conn=null;
}catch(Exception e){
//e.printStackTrace();
}
*/
if(!message.equals("")){
if(select.equals("id")){
try{
MeetManager meetManager=(MeetManager)this.getSessionFactory().openSession().get(MeetManager.class, id);
this.getHibernateTemplate().delete(meetManager);
this.getSessionFactory().openSession().close();
}catch(Exception e){
System.out.println(e);
}
}
}
}
開發者ID:bjut-2014,項目名稱:scada,代碼行數:36,
示例10: info
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String info(){
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
AcctUser sessionUser=(AcctUser)session.get("user");
if(sessionUser==null){
return "login";
}
badges=bbsManager.getAllBadges();
return "info";
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:14,
示例11: resetPasswordForm
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String resetPasswordForm(){
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
AcctUser user=(AcctUser)session.get("user");
if(user==null){
return "login";
}
username=user.getLoginName();
return "resetPassword_form";
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:15,
示例12: doIntercept
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
ActionProxy proxy = actionInvocation.getProxy();
String name = getBackgroundProcessName(proxy);
ActionContext context = actionInvocation.getInvocationContext();
Map session = context.getSession();
HttpSession httpSession = ServletActionContext.getRequest().getSession(true);
Boolean secondTime = true;
if (executeAfterValidationPass) {
secondTime = (Boolean) context.get(KEY);
if (secondTime == null) {
context.put(KEY, true);
secondTime = false;
} else {
secondTime = true;
context.put(KEY, null);
}
}
//sync on the real HttpSession as the session from the context is a wrap that is created
//on every request
synchronized (httpSession) {
BackgroundProcess bp = (BackgroundProcess) session.get(KEY + name);
if ((!executeAfterValidationPass || secondTime) && bp == null) {
bp = getNewBackgroundProcess(name, actionInvocation, threadPriority);
session.put(KEY + name, bp);
performInitialDelay(bp); // first time let some time pass before showing wait page
secondTime = false;
}
if ((!executeAfterValidationPass || !secondTime) && bp != null && !bp.isDone()) {
actionInvocation.getStack().push(bp.getAction());
final String token = TokenHelper.getToken();
if (token != null) {
TokenHelper.setSessionToken(TokenHelper.getTokenName(), token);
}
Map results = proxy.getConfig().getResults();
if (!results.containsKey(WAIT)) {
LOG.warn("ExecuteAndWait interceptor has detected that no result named 'wait' is available. " +
"Defaulting to a plain built-in wait page. It is highly recommend you " +
"provide an action-specific or global result named '{}'.", WAIT);
// no wait result? hmm -- let's try to do dynamically put it in for you!
//we used to add a fake "wait" result here, since the configuration is unmodifiable, that is no longer
//an option, see WW-3068
FreemarkerResult waitResult = new FreemarkerResult();
container.inject(waitResult);
waitResult.setLocation("/org/apache/struts2/interceptor/wait.ftl");
waitResult.execute(actionInvocation);
return Action.NONE;
}
return WAIT;
} else if ((!executeAfterValidationPass || !secondTime) && bp != null && bp.isDone()) {
session.remove(KEY + name);
actionInvocation.getStack().push(bp.getAction());
// if an exception occured during action execution, throw it here
if (bp.getException() != null) {
throw bp.getException();
}
return bp.getResult();
} else {
// this is the first instance of the interceptor and there is no existing action
// already run in the background, so let's just let this pass through. We assume
// the action invocation will be run in the background on the subsequent pass through
// this interceptor
return actionInvocation.invoke();
}
}
}
開發者ID:txazo,項目名稱:struts2,代碼行數:77,
示例13: save
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
@Override
public void save() {
Connection conn=null;
try {
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
String []file=new String[10];
/*****************************************************/
file[0]=(String) session.get("meet_id");
file[1]=(String) session.get("meet_name");
file[2]=(String) session.get("meet_title");
file[3]=(String) session.get("meet_content");
file[4]=(String) session.get("people_num");
file[5]=(String) session.get("start_end");
file[6]=(String) session.get("location");
file[7]=(String) session.get("meetroom_num");
file[8]=(String) session.get("useful_time");
file[9]=(String) session.get("room_size");
int meet_id=Integer.valueOf(file[0]);
int people_num=Integer.valueOf(file[4]);
int meetroom_num=Integer.valueOf(file[7]);
int room_size=Integer.valueOf(file[9]);
/*****************************************************/
conn=getConnection();
String sql=
"INSERT INTO `scada`.`meet_manager` (`meet_id`, `meet_name`, `meet_title`, `meet_content`, `people_num`, `start_end`, `location`, `meetroom_num`, `useful_time`, `room_size`) "
+ "VALUES ("+"'"+meet_id+"', '"+file[1]+"', '"+file[2]+"', '"+file[3]+"', '"+people_num+"', '"+file[5]+"', '"+file[6]+"', '"+meetroom_num+"', '"+file[8]+"', '"+room_size+"');";
PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
int row = ps.executeUpdate();
if(row > 0)
System.out.println("�ɹ������" + row + "������");
conn.close();
conn=null;
}catch(Exception e){
e.printStackTrace();
}
}
開發者ID:bjut-2014,項目名稱:scada,代碼行數:48,
示例14: info
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String info(){
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
AcctUser sessionUser=(AcctUser)session.get("user");
if(sessionUser==null){
return "login";
}
//��Ҫget ohers��
user=accountManager.findUserById(sessionUser.getId());
Iterator it = user.getAcctUserInfo().iterator();
while(it.hasNext()) {
userInfo=it.next();
}
if(userInfo.getBirthday()==null||userInfo.getBirthday().trim().equals("")){
System.out.println("birthday is null");
}else{
System.out.println("----------\n"+userInfo.getBirthday());
String[] birthday=new String[2];
birthday=MyStringUtil.getBirthdayYMD(userInfo.getBirthday());
birthdayYear=birthday[0];
birthdayMonth=birthday[1];
birthdayDay=birthday[2];
}
if(userInfo.getAddress()==null||userInfo.getAddress().trim().equals("")){
System.out.println("address is null");
}else{
System.out.println("----------\n"+userInfo.getAddress());
String[] addresses=new String[2];
addresses=MyStringUtil.getAddressSCQ(userInfo.getAddress());
provinces=addresses[0];
city=addresses[1];
district=addresses[2];
}
//��ʾ�û�ȫ��ѫ��
badges=user.getBadges();
try{
rank=accountManager.getUserRankBySql(sessionUser.getId());
}catch(Exception ex){
ex.printStackTrace();
}
return "InfoSuccess";
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:54,
示例15: saveTopic
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String saveTopic(){
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
AcctUser user=(AcctUser)session.get("user");
if(user==null){
return "login";
}
Long nodeId=Long.valueOf(nodeValue);
Node node=bbsManager.getNode(nodeId);
Topic newTopic=new Topic();
newTopic.setAcctuser(user);
newTopic.setNode(node);
newTopic.setCommentCount(0L);
newTopic.setTitle(topic.getTitle());
//�滻��������
newTopic.setContent(MyStringUtil.strReplaces(topic.getContent(), "
","
","","
","
",""));
newTopic.setCreateTime(new Date());
newTopic.setStatus(0);
newTopic.setViewCount(0L);
System.out.println(node.getName());
System.out.println(user.getLoginName());
System.out.println(topic.getTitle());
System.out.println(topic.getContent());
bbsManager.saveTopic(newTopic);
//�����������Ӿ���
user=accountManager.getUser(user.getId());
long experience=user.getExperience();
experience+=5;
List bbsLevels=bbsManager.getAllCommunityLevels();
try {
CommunityLevel newLevel=LevelUtil.getNewLevel(bbsLevels, experience);
user.setExperience(experience);
user.setUser_level(newLevel.getLevels());
accountManager.saveUser(user);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//-------------
return "save_ok";
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:54,
示例16: resetPassword
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String resetPassword(){
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
user=accountManager.findUserByUserNameAndPassword(username, password);
if(user==null){
session.put("tipMsg", "�������");
return "resetPassword_err";
}else{
user.setPassword(Md5PasswordEncoderUtil.zencodePassword(reNewPassword, null));
accountManager.saveUser(user);
session.put("tipMsg", "�������óɹ�");
return "resetPasswordSuccess";
}
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:22,
示例17: saveComment
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String saveComment(){
Topic replyTopic=bbsManager.getTopic(viewTopicId);
System.out.println(replyTopic.getTitle());
System.out.println(commont);
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
AcctUser user=(AcctUser)session.get("user");
if(user==null){
return "login";
}
Comment newComment=new Comment();
newComment.setAcctuser(user);
newComment.setTopic(replyTopic);
newComment.setCreateTime(new Date());
newComment.setContent(MyStringUtil.strReplaces(commont, "
","
","","
","
",""));
newComment.setStatus(0);
bbsManager.saveComment(newComment);
replyTopic.setCommentCount(replyTopic.getCommentCount()+1);
replyTopic.setLastacctuser(user);
replyTopic.setLastCommentAt(new Date());
replyTopic.setLastCommentUserId(user.getId());
bbsManager.saveTopic(replyTopic);
//�ظ����Ӿ���
user=accountManager.getUser(user.getId());
long experience=user.getExperience();
experience+=5;
List bbsLevels=bbsManager.getAllCommunityLevels();
try {
CommunityLevel newLevel=LevelUtil.getNewLevel(bbsLevels, experience);
user.setExperience(experience);
user.setUser_level(newLevel.getLevels());
accountManager.saveUser(user);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//------------
return SUCCESS;
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:51,
示例18: resetPasswordForm
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String resetPasswordForm(){
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
if (sid.equals("") || userName.equals("")) {
session.put("tipMsg", "���Ӳ�����,����������");
System.out.println("sid or userName is null");
return "resetPassword_err";
}
user=accountManager.findUserByLoginName(userName);
if(user==null){
//�û���������
session.put("tipMsg", "���Ӵ���,���ҵ�ƥ���û�,�����������һ����롣");
return "resetPassword_err";
}
Timestamp outDate = (Timestamp) user.getOutDate();
System.out.println("outDate "+outDate);
if(outDate.getTime() <= System.currentTimeMillis()){ //��ʾ�Ѿ�����
session.put("tipMsg", "�����Ѿ�����,�����������һ����롣");
return "resetPassword_err";
}
String key = user.getLoginName()+"$"+outDate.getTime()/1000*1000+"$"+user.getValidataCode();//����ǩ��
String digitalSignature = DigestUtils.md5Hex(key);// ����ǩ��
if(!digitalSignature.equals(sid)) {
session.put("tipMsg", "���Ӳ���ȷ,�Ƿ��Ѿ�������?��������ɡ�");
System.out.println("sid����ȷ");
return "resetPassword_err";
}else {
//������֤ͨ�� ת��������ҳ��
return "resetPassword_form";
}
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:46,
示例19: resetPassword
點讚 2
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String resetPassword(){
user=accountManager.findUserByLoginName(userName);
user.setPassword(Md5PasswordEncoderUtil.zencodePassword(password, null));
accountManager.saveUser(user);
System.out.println(user.getLoginName());
System.out.println(user.getPassword());
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
session.put("tipMsg", "�������óɹ�");
return "resetPasswordSuccess";
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:19,
示例20: save
點讚 1
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
@Override
public void save() {
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
String infor=(String) session.get("information");
try{
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/scada";
String username = "root";
String password = "root";
Connection conn = (Connection) DriverManager.getConnection(url , username , password);
if (conn != null)
System.out.println("���ݿ����ӳɹ�!");
else
System.out.println("���ݿ�����ʧ��!");
String sql_1="SELECT `id` FROM `scada`.`information`;";
PreparedStatement ps_1 = (PreparedStatement) conn.prepareStatement(sql_1);
ResultSet s_1= ps_1.executeQuery();
int id=0;
while(s_1.next()){
id =s_1.getInt("id");
}
int id_1=id+1;
String sql_2="INSERT INTO `scada`.`information` (`id`,`text`) VALUES ('"+id_1+"','"+infor+"')";
PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql_2);
int row = ps.executeUpdate();
if(row > 0)
System.out.println("�ɹ������" + row + "������");
conn.close();
conn=null;
}catch(Exception e){
e.printStackTrace();
}
}
開發者ID:bjut-2014,項目名稱:scada,代碼行數:55,
示例21: forgetEmail
點讚 1
import com.opensymphony.xwork2.ActionContext; //導入方法依賴的package包/類
public String forgetEmail(){
//System.out.println(user.getLoginName());
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
user=accountManager.findUserByUserNameAndEmail(userName,email);
if(user==null){
session.put("errorMsg", "���䲻����!");
return "forgetEmail";
}
else{
session.put("errorMsg", "");
String secretKey = UUID.randomUUID().toString(); // ��Կ
Timestamp outDate = new Timestamp(System.currentTimeMillis() + 30 * 60 * 1000);// 30���Ӻ����
long date = outDate.getTime() / 1000 * 1000;// ���Ժ����� mySql ȡ��ʱ���Ǻ��Ժ�������
System.out.println("-------------\n");
System.out.println("date="+date);
System.out.println("-------------\n");
String key =user.getLoginName() + "$" + date + "$" + secretKey;
user.setOutDate(outDate);
user.setValidataCode(secretKey);
accountManager.saveUser(user);
//String digitalSignature = DigestUtils.md5Hex(key);
String digitalSignature = DigestUtils.md5Hex(key); //����ǩ��
HttpServletRequest request = ServletActionContext.getRequest();
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String resetPassHref = basePath+"mypace/account/forget!resetPasswordForm.action?sid="+digitalSignature+"&userName="+user.getLoginName();
// ���������������������
EmailUtils.sendResetPasswordEmail(user,resetPassHref);
session.put("tipMsg", "�����������ύ�ɹ�����鿴����"+user.getEmail()+"���䡣");
return "forgetSuccess";
}
}
開發者ID:muzili90,項目名稱:SpringBBS,代碼行數:51,
注:本文中的com.opensymphony.xwork2.ActionContext.getSession方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。