struts 1.x 学习 ---持续更新
最后更新:2009-5-12
1.可以通过在web.xml这配置,统一管理项目中的error显示页面。强……
<error-page>
<error-code>404</error-code>
<location>/commom/404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/commom/500.jsp</location>
</error-page>
<error-code>404</error-code>
<location>/commom/404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/commom/500.jsp</location>
</error-page>
如果需要对特定类型的error做显示,还可以设定 <exception-type>来达到效果
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/commom/system_error.jsp</location>
</error-page>
<error-page>
<exception-type>java.io.IOException</exception-type>
<location>/commom/system_ioerror.jsp</location>
</error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/commom/system_error.jsp</location>
</error-page>
<error-page>
<exception-type>java.io.IOException</exception-type>
<location>/commom/system_ioerror.jsp</location>
</error-page>
oracle 使用心得。持续更新
最后更新日:2009-5-6
- 在jdbc中使用sequence,需要在之前先使用query语句得到新的sequence值。例如:
SELECT
'schema'.'sequence's name'.nextval from dual;--seqNum 就是上面得到的sequence新值
insert into table (id,name) values(seqNum, 'poker');
commit;
一个简单的jQuery插件ajaxfileupload实现ajax上传文件例子
页面代码:
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/ajaxfileupload.js"></script>
<script type="text/javascript">
function ajaxFileUpload(){
$.ajaxFileUpload({
url:'update.do?method=uploader',//需要链接到服务器地址
secureuri:false,
fileElementId:'houseMaps',//文件选择框的id属性
dataType: 'xml', //服务器返回的格式,可以是json
success: function (data, status)
{
$('#result').html('添加成功');
},
error: function (data, status, e)
{
$('#result').html('添加失败');
}
});
}
</script>
<script type="text/javascript">
function ajaxFileUpload(){
$.ajaxFileUpload({
url:'update.do?method=uploader',//需要链接到服务器地址
secureuri:false,
fileElementId:'houseMaps',//文件选择框的id属性
dataType: 'xml', //服务器返回的格式,可以是json
success: function (data, status)
{
$('#result').html('添加成功');
},
error: function (data, status, e)
{
$('#result').html('添加失败');
}
});
}
</script>
服务器代码:
public class UpdateAction extends DispatchAction {
public ActionForward uploader(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UpFormForm upFormForm = (UpFormForm) form;
FormFile ff = upFormForm.getHouseMaps();
try {
InputStream is = ff.getInputStream();
File file = new File("D:/" + ff.getFileName()); // 指定文件存储的路径和文件名
OutputStream os = new FileOutputStream(file);
byte[] b = new byte[1024];
int len = 0;
while ((len = is.read(b)) != -1) {
os.write(b, 0, len);
}
os.close();
is.close();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
public ActionForward uploader(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UpFormForm upFormForm = (UpFormForm) form;
FormFile ff = upFormForm.getHouseMaps();
try {
InputStream is = ff.getInputStream();
File file = new File("D:/" + ff.getFileName()); // 指定文件存储的路径和文件名
OutputStream os = new FileOutputStream(file);
byte[] b = new byte[1024];
int len = 0;
while ((len = is.read(b)) != -1) {
os.write(b, 0, len);
}
os.close();
is.close();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}