亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

求問,@Action(value="/login"在java語句中是什么意思?

求問,@Action(value="/login"在java語句中是什么意思?

森欄 2021-02-16 15:15:39
@Action(value="/login"在java語句中是什么意思
查看完整描述

2 回答

?
慕村225694

TA貢獻1880條經驗 獲得超4個贊

struts中采用注解配置Action需要導入struts2-convention-plugin的jar包  Action  省略getters和setters@ParentPackage("xystruts-default")@Namespace("/login")public class LoginAction extends BaseAction{ private String verifyCode;   @Action(value = "login", results = { @Result(location = "/pages/main.jsp"), @Result(name = "login", location = "/pages/login.jsp") }) public String login() {  String sysVerifyCode = (String) getSession().get("verifyCode");  if (StringHelper.isEmpty(verifyCode) || !sysVerifyCode.equalsIgnoreCase(verifyCode))  {   addActionError("驗證碼錯誤");   return "login";  }  return "success"; }   @Action(value = "logout", results = { @Result(location = "/pages/login.jsp") }) public String logout() {  Map session = getSession();  if (session != null)   session.clear();  return "success"; }}    JSP<form action="login/login.action"></form><a href="login/logout.action">登出</a>其中Result注解中name屬性為空,表示默認為"success"

常用注解如下

Namespace:指定命名空間

ParentPackage:指定父包

Result:提供了Action結果的映射(一個結果的映射)

Results:Result注解列表

ResultPath:指定結果頁面的基路徑

Action:指定Action的訪問URL

Actions:Action注解列表

ExceptionMapping:指定異常映射(映射一個聲明異常)

ExceptionMappings:一級聲明異常的數組

InterceptorRef:攔截器引用

InterceptorRefs:攔截器引用組



查看完整回答
反對 回復 2021-03-18
?
手掌心

TA貢獻1942條經驗 獲得超3個贊

@為java中的注解。使用@Component("loginAction")在服務器容器中生成對應的組件bean。默認的@Component設置的Scope為singleton,即整個容器中只會生成一個這個bean,所有與狀態相關的Bean需要聲明為prototype。而Struts2的Action Bean正好都是有狀態的,顯然應該聲明為prototype。

查看完整回答
反對 回復 2021-03-18
  • 2 回答
  • 0 關注
  • 443 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號