Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure WebWork

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to configure WebWork for you. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

In terms of tags, WebWork configures these tags in strict order, and the correct order is as follows:

First < result-types >, there must be < result-type/ > item; then < interceptors >, there must be < interceptor/ > item; then < default-interceptor-ref name= "completeStack" > default-interceptor-ref >; then < global-results >, there must be < result/ > item Then < global-exception-mappings >, subitems such as < exception-mapping result= "errorPage" exception= "java.lang.Exception" / > * * are < action/ >.

* is

< action name= "test" > < interceptor-ref name= "exception" / > < interceptor-ref name= "basicStack" / > < exception-mapping exception= "com.acme. CustomException" result= "custom_error" / > < result name= "custom_error" > custom_error.ftlresult > < result name= "success" type= "freemarker" > test.ftlresult > action >

Webwork runs the process:

The execute () method is executed by default, which returns SUCCESS by default

< Script language= "JavaScript" src= "/ js/pagenumber.js" > < / Script > < script Language= "JavaScript" > listNumUrl ("courseInfoList.action?&pageNum=", ${pageNum}, ${allPageNum}); < / script >

How Ognl works:

OgnlValueStack stack=new OgnlValueStack ()

Stack.push (new User ()): / / first push the object to be assigned into the stack

Stack.setValue ("name", "erica"); / / assign a value to the attribute name name specified by the top stack object User

HttpSession is an interface

The Properties implementation inherits HashTable (implements the Map interface), that is, it also holds value-key objects, and its setProperty ("name", "value") is essentially stored in HashTable.

Default is not ajax

< action name= "itemPersonalInput" class= "cn.com.s520.course.ItemPersonalInputAction" > < interceptor-ref name= "fileUpload" > < param name= "allowedTypes" > application/msword,image/gif, image/jpeg,image/pjpeg Application/x-shockwave-flash param > < param name= "maximumSize" > 10485760param > interceptor-ref > < interceptor-ref name= "basicStack" / > < result name= "input" type= "freemarker" > / course/ItemPersonalInput.ftlresult > < result name= "error" type= "freemarker" > course/ItemPersonalInput.ftlresult > < result name= "success" type= "redirect" > / itemPersonalList.actionresult > action >

Private File images

Private String imagesContentType

Private String imagesFileName;// gets a file name without a path, such as test.jpg

< result name= success "type=" stream "> < param name=" contentType "> image/jpegparam > < param name=" inputName "> imageStreamparam > < param name=" contentDisposition "> filename=" logo.png "param > < param name=" bufferSize "> 4096param > result >

1, < param name= "contentType" > application/x-msdownloadparam >

Just set contentType to application/x-msdownload. In this way, the browser will ensure that a dialog box for downloading the file will pop up.

2 steam result inputName this is more important, this name is the name of the input stream, which will be looked up in the implementation class of steam result according to the expression of steam result.

ContentDisposition this is the name of the file saved on the client side after download.

3, another parameter: contentLength is the size of the downloaded file. There seems to be something wrong with the stream result implementation of webwork. It cannot be set dynamically according to the size of the file, but can only be written dead.

The meaning of this WebWork configuration parameter is to tell browsing the size of the downloaded file so that the browser can display the progress bar correctly. If this function is important, you can write a new RESULT to implement it.

< result > / form.jspresult > if not specified, the default is success < action name= "userReg" class= "com.opensymphony.xwork.ActionSupport" > < result name= "input" > / app/userreg.ftlresult > < / action >

The expected page will not appear here, because the default is success, and it will not go to the input page we specified

< result name= "no-content" type= "header" > < param name= "status" > 204param > < param name= "headers.customHeaderA" > Aparam > < param name= "headers.customHeaderB" > Bparam > result >

Chain view:

In the same package, type can be set to chain, and the extension of the corresponding action can be left unwritten.

< result name= "error" type= "chain" > < param name= "actionName" > barparam > result >

In different bags.

< result name= errorPage "type=" chain "> < param name=" namespace "> / param > < param name=" actionName "> barparam > result >

Or set type to redirect and redirect to the past

< action name= index "class=" com.opensymphony.xwork.ActionSupport "> < result name=" success "type=" redirect "> / course/courseInfoList.actionresult > action > < default-interceptor-ref name=" defaultStack "/ >

This is only used if you do not have an interceptor set up. If WebWork has configured the interceptor, this will not be called.

This is the end of the article on "how to configure WebWork". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report