ognl and token and a little method at the beginning

Store data in ValueStack

 

The first way to get the value stack ( very troublesome)

 

ActionContext actionContext = ActionContext . getContext();
Map<String,Object> reqmap = (Map<String, Object>) actionContext.get("request");
ValueStack valueStack = (ValueStack) reqmap.get("struts.valueStack");

 

 

 

the second way

 

HttpServletRequest request= ServletActionContext.getRequest();
ValueStack valueStack = (ValueStack)request.getAttribute(“struts.valueStack”);

 

 

 

third way

 

ActionContext actionContext = ActionContext.getCOntext();
ValueStack valueStack = actionContext.getValueStack();

 

 

 

This second and third is a bit like yesterday's, it seems to be the way to get the context ?

wait i see

Oh no , it's Session , it's all inexplicable to the request

Then take out the quoted name from the request

 

Store data on the value stack

valueStack.put(new Student( " Little Black " ,20));

This is placed on the top of the stack, and the attribute of the student class is regarded as name ,

 

Another one that can also be stored is to put it directly outside and use private ,

 

setValue(String str,Object obj)

Adding a # sign is to store a key-value pair in the ActionContext , the key is name , and the value is pipipi

valueStack.setValue(#name,pipipipi);

Without the # sign, the first attribute name is overwritten. If there is no such attribute name, an error will be reported.

valuStack.setValue(name,bibibib);

 

 

set(String key ,Object obj)

Encapsulate a hashmap and use the value of the key as the key,

valueStack.set(stu,new new Student(xiaohua,21);

valueStack.push(new Student(xiaohua,22);

 

I have to see what this set and push are for

 

 

This is a JSP page

I didn't want to write, I really don't know what to write

Just barely write

<s:debug></s:debug>

<s:property value=[0].name/>

<s:property value=[1].name/>

<s:property value=[2].name/>

The problem is that I put a lot of useless things in the back (the back is on the top)

Then it starts drawing frames one by one,

1,2,3,4,56

These values ​​are always the first

 

Well, let's see how the implementation works

 

ActionContext context = ActionContext.getContext();

ValueStack valueStack=context.getValueStack();

Object obj = ValueStack.findValue(name);

out.println(obj);

这原理好特么浅啊。。。。。。。

 

下一项吧

serlvet中的查找顺序

pageContext,request,session,application

Struts中使用el表达式的搜索顺序

request.ValueStack,ActionContext,Session,Applilcation

从值栈找不到,会去actioncontext中查找

 

 

  没有使用var,每次迭代出来的对象放入 值栈的栈顶                     

   

      <s:iterator value="stuts" status="st">
           <tr>
              <td><s:property value="#st.count"/></td>
              <td><s:property value="name"/></td>
              <td><s:property value="age"/></td>
           </tr>
         </s:iterator>  
       </table>
 
  <s:iterator value="stuts.{?#this.age>22}" status="st">
           <tr>
              <td><s:property value="#st.count"/></td>
              <td><s:property value="name"/></td>
              <td><s:property value="age"/></td>
           </tr>
         </s:iterator>  
 
 
     <s:iterator value="stuts" var="stu" status="st">
           <tr>
              <td><s:property value="#st.count"/></td>
              <td><s:property value="#stu.name"/></td>
              <td><s:property value="#stu.age"/></td>
           </tr>
         </s:iterator>

 

 

 

     <!--

            ognl投影:筛选字段                                      

         -->

         <s:iterator value="stuts.{name}" status="st">

           <tr>

              <td><s:property value="#st.count"/></td>

              <td><s:property /></td>

           </tr>

         </s:iterator>  

       </table>

       

自己理解吧贼简单看一遍就懂了但是我现在不想看了嘤嘤嘤

 

 

 

 

哦对这个东西叫令牌,想了半天没想起来

首先在jsp页面上写

<s:token></s:token>

然后再Struts中配置

就是加个拦截器的功效

<interceptor-ref name=token></interceptor-ref>

记得把默认加进去

<interceptor-ref name=defaultStack></

 

啊不写了 还有个什么界面

不管了

 

 

出道题:暂时想的

1:用户登录

(设上用户名密码验证,后台验证)

2:登录后看到一个表

(用ognl看出来)

(这个表就是注册用户表吧)

3:新增用户

(时间格式,后台验证)

(设置回显,设置回显样式)

 

不过拦截器是干嘛来着,哦对,看有没有Session

可以用在show界面前面,ok就这样

也可以想一点别的,关于拦截器

 

 

写项目的小总结,边写边总结,

那估计会写的更慢了。。。

继承的是ActionSupport,实现的是 ModelDriven接口

怎么记不住呢

 

验证器怎么写来着。。。

 

总算被我(在帮助下)找到了原始的文件

验证器源文件:

Web App Libraries

xwork-core-2.3.15.3.jar下(dtd约束也在)

com.opensymphony.xwork2

validator

validators

default.xml

给自己挖的两个坑

只用写 类名-动作名-validation.xml

就可以了

不过是动作名!!动作名!!

记得还要写返回结果,所以才能看到啊(摊手)

<result name=input>/login.jsp</result>

 

C3P0怎么写又忘了。。。。。。。。。。。。

private static DataSource ds = new ComboPooledDataSource();

 

public static DataSource getDataSource(){

return ds;

 

遇到了谜一样的数据库链接失败问题不管了

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326571095&siteId=291194637