a small project

I have a little more stuff today, I don't know if I can finish it

But typing makes me tired

It's really troublesome to jump back and forth between windows

Can't we write one way to one way of loving love, brother?

 

 

 

1

Let me talk about the two mistakes I encountered yesterday

The c3po configuration file is to be placed under src

stupid.

Then I want to write C3P0Utils

 

 

 

pubic class C3P0Utils
{
private static DataSource ds = new ComboPooledDataSource();
public static DataSource getDataSource()
{
return ds;
}
}

 

 

Write on both sides!

 

private static DataSource ds = new CooboPooledDataSource();
private static DataSource ds= new CooboPooledDataSource();

 

 

 

2

 

Several database query methods, I am still not very skilled

Single query:

 

return qr.query(“select * from table where name=?”,
new BeanHander<User>(User.class),user.getname);

 

 

 

 

Added:
 return qr.update("insert into table(attribute, attribute) values(?,?), user.get attribute)
 
Revise:
return qr.update("update table set attribute=?, attribute=?", user.get attribute);
 
delete
return qr.update(“delete from table where useId=?”,userId);
 

 

 

 

fuzzy query

This method is really fun

can write again

 

 

public List<User> find(User u)
{
if(StringUtils.isBlank(u.getName)&&StringUtils.isBlank(u.getPassword))
{
return findAll();
}
else
{
String sql=”select * from table where 1=1”;
List<Object> list = new ArrayList<Object>();
if(StringUtils.isBlank(u.getName()))
{
sql+=” and userName like ?”;
list.add(u.getName);
}
if(StringUtils.isBlank(u.getPassword))
{
sql+=” and userPassword like ?”;
}
return qr.query(sql,new BeanListHander<User>(User.class),list.toArray());
}
return null;
}

 

 

 

Definitely not finished. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

 

 

Go ahead and write it. Where did you write it yesterday? Obviously I forgot. I think about it. I just finished writing the dao method.

There are three Actions left , xml , and JSP

JSP is so boring, wait a minute

write xml _

The general direction is almost the same, mainly the details.

 

XML

1

<constant name=struts.devMode value=true></constant>

This is changed without restarting, although I found that he has no soft use

<constant name=struts.ognl.allowStaticMethodAccess value=true></constant>

Know your name, classmates know your name

Allow static method calls === "channel open, permission open, beep beep

Although I forgot how to use it, I will write about it later and come back to it.

2

redirect

For example, if you want to return to the interface to refresh after adding, you can use this to jump directly to the method

Let's find out, can we write it ourselves?

can not

All right

 

hey found it, it's disgusting to deal with the file wait i write it alone

 

It's actually quite simple.

<result type=redirectAction name=success>findAll</result>

redirectAction redirectAction redirectAction redirectAction

redirectAction redirectAction redirectAction redirectAction

redirectAction redirectAction redirectAction redirectAction

 

The rest is easy, let's write files

 

Knock on the blackboard: about file upload and download ( nth repetition)

 

先从JSP写起来

enctype=multipart/form-data

(对了命名空间这个命名在包上)

 

这个file有点出乎意料啊,,,

<s:file name=upload size=30></s:file>

 

然后应该写action

但是我就是不想写,太麻烦了,而且我都写过好几回了也不会

也不是不会吧就是没有深入搞懂

 

 

直接写到xml里面

上传

 

<interceptor-ref name=”defaultStack”>
<param name=”fileUpload.allowedExtensions”>dox</param>
</interceptor-ref>

 

 

这个是设置类型的 不设置的也行

 

写一个下载,下载还是比较好玩的

 

<result type=stream>这个是type

<param name=inputName>inputStream</param>这个inputStream就是流

 

 

 

 

<param name="contentType">application/octet-stream</param>
<param name="contentDisposition">attachment;filename=${@java.net.URLEncoder@encode(oldFileName,"utf-8")}</param>
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

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