偶的项目错误记载

myhalfsea posted @ 2011年4月07日 11:35 in JAVA , 1501 阅读

2011/04/05   关于struts2的错误

我用struts2和hibernate3、dwr来做毕业设计,原以为周多一周局可以搞定,但有两个错误却让我检查了3天。

1、看代码

public class Login extends ActionSupport {
    Login(){
        System.out.println("xxxxxxxxxxxx");
    }
    public String pointLogin(){
        HttpServletRequest request=ServletActionContext.getRequest();
        String userid = request.getParameter("userid");
        String password = request.getParameter("password");
        System.out.println(userid+": " + password);
        return "success";
    }
}

   这是我用于测试登录页是否能正确跳转的代码,你发现那里错了吗?

   一般情况下,他是没错的,但是在struts2框架下,该项目根本无法启动!为什么?因为构造方法是默认权限(default),且看default权限的描述:默认权限(default)类,数据成员,构造方法,方法成员,都能够使用默认权限,即不写任何关键字。默认权限即同包权限,同包权限的元素只能在定义它们的类中,以及同包的类中被调用。  不仅仅default不可以,protected也不可以。所以,如果你一定要写构造方法,那么请加上public。

2、先看看struts2.xml配置文件:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">

<struts>
    <constant name="struts.i18n.encoding" value="UTF-8"></constant>
    <constant name="struts.locale" value="zh_CN"></constant>
    <package name="count" namespace="/count" extends="struts-default">
        <interceptors>
            <interceptor name="userInterceptor" class="com.common.UserInterceptor"></interceptor>
            <interceptor-stack name="myInstance">
                <interceptor-ref name="defaultStack"></interceptor-ref>
                <interceptor-ref name="userInterceptor"></interceptor-ref>
            </interceptor-stack>
        </interceptors>
        <default-interceptor-ref name="myInstance"></default-interceptor-ref>
        <global-results>
            <result name="error">login.jsp</result>
        </global-results>
        <action name="login" class="com.action.Login" method="pointLogin">
            <result name="success">WEB-INF/jsp/content.jsp</result>
            <result name="error">login.jsp</result>
        </action>
    </package>

</struts>

这段代码有错吗?没有!我也是这么觉得的。但是出现一个问题:在我点击“登录”按钮后,页面跳转了,Login()构造方法也也执行了,但是却是空白页面,查看源代码也是神马也木有!我找哇找,重写了4个project,最后我把struts.xml中关于拦截器的代码注释了,然后就好了……啊啊啊……啊啊……啊……………………我表示,我的拦截器里面神马也没写,我就是先配置好,放在那儿也不行哇!!!他就那样给我全过滤了!血的教训……………………

 

edpost.in 说:
2023年4月16日 16:14

Our team comprises of professional writers & citizen journalists with diverse range of interest in Journalism who are passionate about publishing the Education Updates with transparency in general public interest. edpost.in edpost is a initiative of professional writers who have come together for dedicated news coverage of latest happenings around the country (India).

website 说:
2024年12月04日 15:17

I like viewing web sites forward for more.

here 说:
2024年12月04日 15:18

Youre so awesome! I don’t intend Ive read anything similar to this prior to. So wonderful to find someone with some original thoughts on this subject. realy thank you for starting this up. this website is something that is required online, a person with a little creativity. useful job for bringing something brand-new to the net! This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging Looking to reading your next post. Terrific article! This is the kind of info that are meant to be shared around the net. Shame on Google for not positioning this post higher! Come on over and visit my website. Nice blog here! Thanks =)|

reference material 说:
2024年12月04日 15:20

Set aside my effort to perust what I was looking for!...This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!.

토토디펜드 说:
2024年12月04日 15:23

Your content is nothing short of bmuch as you have been willing to share information with us. We will forever admire all you have done here because you have made my work as easy as ABC.

먹튀위젯 说:
2024年12月04日 15:25

Hey there! I could have sworn I’ve been to this website before but after reading through some of the post I realized it’s new to me. Nonetheless, I’m definitely happy I found it and I’ll be book-marking and checking back frequently 7mcn 

casinofriendskr 说:
2024年12月04日 15:26

Took me time to read all the co all the commenters here! It’s always nice when you can not only be informed, but also entertained

information 说:
2024年12月04日 15:28

When I initially commented many various angles. Its like men and women are not involved unless it is one thing to do with Girl gaga! Your individual stuffs great. Always handle it up!

click here 说:
2024年12月04日 15:33

Introductory You got a greike this website. He used to be entirely right. This submit actually made my day. You cann’t imagine just how much time I had spent for this information! Thank you!

casinohunter24 说:
2024年12月04日 15:35

hanks for sharing your iere u got this from. thank you . Good post. Thanks for sharing with us. I just loved your way of presentation. I enjoyed reading this .Thanks for sharing and keep writing

read more 说:
2024年12月04日 15:36

I'm looking for a lot of data on this topic. The article I've been looking for in the meantime is the perfect article. Please visit my site for more complete articles with him!

here 说:
2024年12月04日 15:52

After I originally left a comment I seem to have clicked on the -Notify me when new comments are added- checkbox and from now on every time a comment is added I receive four emails with the same comment. Perhaps there is an easy method you are able to remove me from that service? Many thanks! Greetings! Very helpful advice in this particular article! It's the little changes which will make the most important changes. Many thanks for sharing!| You are so interesting! I do not think I've read a single thing like this before. So wonderful to find someone with a few original thoughts on this subject. Really.. thank you for starting this up. This site is something that's needed on the internet, someone with a bit of originality! It­s hard to come by educated people about this subject, however, you seem like you know what youíre talking about! Thanks

먹튀검증 说:
2024年12月04日 16:20

Fabulous post, you have denoted out some fantastic points, I likewise think this s a very wonderful website. I will visit again for more quality contents and also, recommend this site to all. Thanks.

토디야 说:
2024年12月04日 16:32

This is actually the kind of look out for such info.

get more info 说:
2024年12月04日 16:34

We are looking for a lot of data on this item. In the meantime, this is the perfect article I was looking for . Please post a lot about items related to !!! I am waiting for your article. And when you are having difficulty writing articles, I think you can get a lot of help by visiting my 

here 说:
2024年12月04日 16:45

Thanks for such a fantastic blog. Where else could anyone get that kind of info written in such a perfect way? I have a presentation that I am presently writhing on, and I have been on the look out for such great information. 

검증의신 说:
2024年12月04日 16:59

html i’ve been brown hold travelling this blog very frequently.

good contents 说:
2024年12月04日 17:07

What i do not understood is in reality how you are not really a lot more well-preferred than you might be right now. You are very intelligent. You understand thus significantly on the subject of this subject, produced me in my opinion believe it from a lot of varied angles. Its like women and men aren’t involved unless it’s something to accomplish with Lady gaga! Your individual stuffs great. All the time handle it up! What’s up it’s me, I am also visiting this web page on a regular

먹튀마루 说:
2024年12月04日 17:10

html i’ve been browsing on line more than three hours these days, but i in no way located any interesting article like yours. It’s pretty well worth enough for me. In my view, if all site owners and bloggers made proper content material as you probably did, the net will be lots more useful than ever earlier than . Very useful records shared in this text, nicely written! I might be studying your articles and the use of the informative tips. Searching ahead to study such informed articles . I lately came at some stage in your blog and were analyzing along. I idea i might depart my first remark. I do now not understand what to mention except that i've enjoyed studying. Quality weblog. I am capable of hold travelling this blog very frequently.

here 说:
2024年12月04日 17:12

It's really great. Thank you for providing a quality article. There is something you might be interested in. Do you know ? If you have more questions, please come to my site and check it out!

Learn more 说:
2024年12月04日 17:16

Nice to be visiting your blog once more, it has been months for me. Well this article that ive been waited for therefore long. i want this article to finish my assignment within the faculty, and it has same topic together with your article. Thanks, nice share.

Learn more 说:
2024年12月04日 20:05

I like viewing web forward for more.

먹튀닥터 说:
2024年12月04日 20:19

An impressive share, I simply offered this onto a colleague that was doing a little evaluation on this. As well as he in fact bought me breakfast due to the fact that I discovered it for him. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the moment to review this, I really feel strongly concerning it and like reading more on this subject. Ideally, as you end up being experience, would certainly you mind upgrading your blog site with more information? It is very helpful for me. Big thumb up for this post! Quality posts is the secret to interest the people to visit the site, that’s what this web page is providing.| Nice post. I learn something totally new and challenging on websites I stumbleupon every day. It’s always interesting to read through articles from other authors and practice a little something from other websites. 

spotterdayinfraero 说:
2024年12月04日 21:58

I was very impressed with your writing skills along with your blog format. Is this a paid topic or did you edit it yourself? Anyway, keep writing with great quality.

good information 说:
2024年12月04日 21:59

Wow! Thank you! I permanently needed to write on my blog something like that. Can I implement a part of your post to my blog? With havin so much written content do you ever run into any issues of plagorism or copyright infringement? My blog has a lot of completely unique content I’ve either written myself or outsourced but it appears a lot of it is popping it up all over the internet without my authorization. Do you know any ways to help reduce content from being ripped off? I’d truly appreciate it. Excellent beat ! I would like to apprentice while you amend your website, how can i subscribe for a blog site? The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear concept


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta
Butterfly Theme | Design: HRS Hersteller of mobile Hundeschule.