1

rewrite url mod の使用時に問題が発生しました

私の問題は、それを使用するときです。admincpのログインフォームに移動します

ユーザー名とパスワードを入力すると、HTTP 500 ステータスが表示されますが、Tomcat ログにスタックトレースがありませんか???

私のコード

Struts.xml

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

<struts>


    <package name="admincp" namespace="/admincp" extends="struts-default">
        <interceptors>
            <interceptor name="login" class="org.dejavu.software.interceptor.LoginInterceptor" />
            <interceptor-stack name="stack-with-login">
                <interceptor-ref name="login"/>
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
        </interceptors>
        <default-interceptor-ref name="stack-with-login"/>

        <global-results>
            <result name="login">login.jsp</result>
        </global-results>

        <action name="logincp" class="org.dejavu.software.view.AdminLoginAction">
            <interceptor-ref name="defaultStack" />
            <result name="success">dashboard.jsp</result>
            <result name="input">login.jsp</result>
            <result name="error">login.jsp</result>
        </action>

    </package>  

</struts>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
    <display-name>dejavuSoft</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>





    <filter>
        <filter-name>UrlRewriteFilter</filter-name>
        <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
        <init-param>
            <param-name>logLevel</param-name>
            <param-value>WARN</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>UrlRewriteFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

      <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.FilterDispatcher
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>

</web-app>

ログイン.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html>
    <head>
        <title>Deja vu! | Login - Admin Control Panel</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/login.css" />
    </head>
    <body>
        <img src="img/loginLogo.png" id="logo"/>
        <s:actionerror/>
        <s:form action="logincp">
            <s:textfield name="username" value="username..." id="txtusername" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="if(this.value=='') this.value=this.defaultValue;"/>        
            <s:password name="password" value="password..." id="txtpassword" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="if(this.value=='') this.value=this.defaultValue;"/><br/>
            <s:submit value="Enter Admin Panel" id="btLogin"/>
        </s:form>
        <img src="img/dejavu.png" id="icon"/>    
        <div id="forget">
            Forget Password | Forget Username
        </div>

    </body>
    <footer>
        Footer
    </footer>
</html>

ログインアクション

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.dejavu.software.view;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;
import org.apache.struts2.interceptor.SessionAware;
import org.dejavu.software.dao.UserDAO;
import org.dejavu.software.model.GroupMember;
import org.dejavu.software.model.User;

/**
 *
 * @author Administrator
 */
public class AdminLoginAction extends ActionSupport {

    private static final long serialVersionUID = -1457633455929689099L;
    private User user;
    private String username, password;
    private String role;
    private UserDAO userDAO;
    private GroupMember group;    

    public AdminLoginAction() {
        userDAO = new UserDAO();

    }

    @Override
    public String execute() {
        String result = null;        
        if (getUsername().length() != 0 && getPassword().length() != 0) {
            setUser(userDAO.checkUsernamePassword(getUsername(), getPassword()));            
            if (getUser() != null) {
                for (GroupMember g : getUser().getGroups()) {
                    boolean admincp = g.getAdminpermission().contains("1");
                    if (admincp == true) {
                        Map session = ActionContext.getContext().getSession();  
                        session.put("userLogged", getUsername());
                        session.put("passwordLogged", getPassword());
                        result = "success";
                    } else {
                        result = "error";
                    }
                }

            }
        }        
        return result;
    }

    @Override
    public void validate() {
        if (getUsername().length() == 0) {
            addFieldError("username", "Username is required");
        }
        if (getPassword().length() == 0) {
            addFieldError("password", getText("Password is required"));
        }

    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public GroupMember getGroup() {
        return group;
    }

    public void setGroup(GroupMember group) {
        this.group = group;
    }


}

ウェブエラー:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
    org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
    org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
    org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
    com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:501)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:432)
    org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)
    org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)
    org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
    org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
    org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.22 logs.
4

0 に答える 0