Jsp页面跳转的代码,运行出来之后出现空白网页

物联天下 发布于 2012/01/30 10:37
阅读 5K+
收藏 0

我目前正在做两个页面之间的跳转,可运行的时候老是出现空白,我把代码列出来请各位大侠,帮我看看哪出了问题:

1、登陆JSP

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<html>
<head>
<title>登录系统</title>
<style type="text/css">
.tablebg {
 background-image: url("${pageContext.request.contextPath}/deng/img/deng.jpg");
}
body {
 background-image: url("${pageContext.request.contextPath}/deng/img/deng.jpg");
}
.font1 {
    font-size: 18px;
    font-weight:bold;
    color:  000000  //#FFFFFF
}
</style>
<link rel="stylesheet" href="<%=request.getContextPath()%>/common/extjs/resources/css/ext-all.css" type="text/css"></link>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-base.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-all.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
               function show(){
                        var username=document.getElementById("username").value;
                        var password=document.getElementById("password").value;
                        window.open("./loginmethod.action",null,"center:yes;dialogWidth:300px;dialogHeight:300px;");
               }
               function close(){
                        var username=document.getElementById("username").value;
                        var password=document.getElementById("password").value;
                        window.open("closelogin.action",null);
               }
                       
</script>
</head> 
<body>
<form id="loginform" method="post">
<table width="10%" height="10%" align="center" valign="middle">
     <tr>
     <td width="250" height="100">
     </td>
     </tr>
     <tr>
     <td width="250" height="100">
     <font face="宋体" size="16" color="red">
     &nbsp&nbsp登&nbsp录&nbsp系&nbsp统&nbsp
     </font>
     </td>
     </tr>
</table>
<table width="10%" height="10%" align="center" valign="middle">
     <tr>
     <td width="250" height="5" align="center" valign="top">
     <font face="宋体" color="blue">
             用&nbsp户&nbsp<input type="text" id="usernamer" size="22">
     </font>
     </td>
     </tr>
     <tr>
     <td width="250" height="5" align="center" valign="top">
     <font face="宋体" color="blue">
             密&nbsp码&nbsp<input type="text" id="password" size="22">
     </font>
     </td>
     </tr>
     <tr>
     <td width="250" height="5" align="center" valign="middle">
     <font face="宋体">
     &nbsp&nbsp&nbsp&nbsp&nbsp<input type="button" value="登陆" onclick="show()">
     &nbsp<input type="button" value="关闭" onclick="close()">
     </font>
     </td>
     </tr>
</table>
</form>
</body>
</html>

2、需要跳转到的页面11JSP

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
李白诗赋
</title>
</head>
<table width="20%" height="20%" align="center" valign="top">
    <tr>
         <td width="250" height="250" align="center"></td>
    </tr>
    <tr>
         <td width="250" height="50" align="center">
          <font face="黑体" size="4" color="red">子秋夜歌&nbsp&nbsp&nbsp&nbsp</font></td>
    </tr> 
    <tr> 
    <tr>
         <td width="250" height="50" align="center">
          <font face="黑体" color="blue">长安一片月,万户捣衣声。</font></td>
    </tr> 
    <tr>
         <td width="250" height="50" align="center">
         <font face="黑体" color="blue">秋风吹不尽,总是玉关情。</font></td>
    </tr>
    </tr>
         <td width="250" height="50" align="center">
         <font face="黑体" color="blue">何日平胡虏,良人罢远征。</font></td>
    </tr>
</table>   
</html> 

3、Action文件

package deng.action;
public class loginAction {
   private String username;
         private String password;
         public String getUsername(){
          return username;
         }
         public void setUsername(String username)
         {
          this.username=username;
         }
         public String getPassword(){
          return password;
         }
         public void setPassword(String password){
          this.password=password;
         }
         public String loginMethod(){
          String uid=getUsername();
          String pwd=getPassword();
          String L=(uid+pwd);
          if(L!=null){
        return "SUCCESS";
          }
          return "NONE";
         }
         public String closeLogin(){
          return "SUCCESS";
         }
}

4、struts.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<struts>
       <package name="deng.action" extends="json-default">
          <action name="loginmethod" class="loginAction" method="loginmethod">
          <result name="SUCCESS" >login/11Jsp.jsp</result>
          <result name="NONE">login/login.jsp</result>
          </action>
          <action name="closelogin" class="loginAction" method="closelogin">
          <result name="SUCCESS">login/login.jsp</result>
          </action>
       </package>
</struts>

5、web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  <init-param>
   <param-name>struts.i18n.encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
</web-app>
小弟新学JAVA,请各位大神多多指点,小弟就感激涕零了

加载中
0
虫虫
虫虫
建议楼主把代码格式化一下
物联天下
物联天下
好的立即改正
虫虫
虫虫
@物联天下 : 不是,是格式化一下。在编辑插入代码的时候,可以选择代码的类型,然后这些代码显示的时候就会带颜色,看着舒服。
物联天下
物联天下
我直接从编译器里面拷过来的,你是希望我把代码调整一下?
0
物联天下
物联天下

运行的时候没有问题,但页面无法显示出来

0
物联天下
物联天下

1、login.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<html>
<head>
<title>登录系统</title>
<style type="text/css">
.tablebg {
 background-image: url("${pageContext.request.contextPath}/deng/img/deng.jpg");
}
body {
 background-image: url("${pageContext.request.contextPath}/deng/img/deng.jpg");
}
.font1 {
    font-size: 18px;
    font-weight:bold;
    color:  000000  //#FFFFFF
}
</style>
<link rel="stylesheet" href="<%=request.getContextPath()%>/common/extjs/resources/css/ext-all.css" type="text/css"></link>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-base.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-all.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
               function show(){
                        var username=document.getElementById("username").value;
                        var password=document.getElementById("password").value;
                        window.open("./loginmethod.action",null,"center:yes;dialogWidth:300px;dialogHeight:300px;");
               }
               function close(){
                        var username=document.getElementById("username").value;
                        var password=document.getElementById("password").value;
                        window.open("closelogin.action",null);
               }
                       
</script>
</head> 
<body>
<form id="loginform" method="post">
<table width="10%" height="10%" align="center" valign="middle">
     <tr>
     <td width="250" height="100">
     </td>
     </tr>
     <tr>
     <td width="250" height="100">
     <font face="宋体" size="16" color="red">
     &nbsp&nbsp登&nbsp录&nbsp系&nbsp统&nbsp
     </font>
     </td>
     </tr>
</table>
<table width="10%" height="10%" align="center" valign="middle">
     <tr>
     <td width="250" height="5" align="center" valign="top">
     <font face="宋体" color="blue">
             用&nbsp户&nbsp<input type="text" id="usernamer" size="22">
     </font>
     </td>
     </tr>
     <tr>
     <td width="250" height="5" align="center" valign="top">
     <font face="宋体" color="blue">
             密&nbsp码&nbsp<input type="text" id="password" size="22">
     </font>
     </td>
     </tr>
     <tr>
     <td width="250" height="5" align="center" valign="middle">
     <font face="宋体">
     &nbsp&nbsp&nbsp&nbsp&nbsp<input type="button" value="登陆" onclick="show()">
     &nbsp<input type="button" value="关闭" onclick="close()">
     </font>
     </td>
     </tr>
</table>
</form>
</body>
</html>

2、登录成功跳转的页面11.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
李白诗赋
</title>
</head>
<table width="20%" height="20%" align="center" valign="top">
    <tr>
         <td width="250" height="250" align="center"></td>
    </tr>
    <tr>
         <td width="250" height="50" align="center">
          <font face="黑体" size="4" color="red">子秋夜歌&nbsp&nbsp&nbsp&nbsp</font></td>
    </tr> 
    <tr> 
    <tr>
         <td width="250" height="50" align="center">
          <font face="黑体" color="blue">长安一片月,万户捣衣声。</font></td>
    </tr> 
    <tr>
         <td width="250" height="50" align="center">
         <font face="黑体" color="blue">秋风吹不尽,总是玉关情。</font></td>
    </tr>
    </tr>
         <td width="250" height="50" align="center">
         <font face="黑体" color="blue">何日平胡虏,良人罢远征。</font></td>
    </tr>
</table>   
</html> 

3、login.action
package deng.action;
public class loginAction {
   private String username;
         private String password;
         public String getUsername(){
          return username;
         }
         public void setUsername(String username)
         {
          this.username=username;
         }
         public String getPassword(){
          return password;
         }
         public void setPassword(String password){
          this.password=password;
         }
         public String loginMethod(){
          String uid=getUsername();
          String pwd=getPassword();
          String L=(uid+pwd);
          if(L!=null){
        return "SUCCESS";
          }
          return "NONE";
         }
         public String closeLogin(){
          return "SUCCESS";
         }
}

4、struts-login.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<struts>
       <package name="deng.action" extends="json-default">
          <action name="loginmethod" class="loginAction" method="loginmethod">
          <result name="SUCCESS" >login/11Jsp.jsp</result>
          <result name="NONE">login/login.jsp</result>
          </action>
          <action name="closelogin" class="loginAction" method="closelogin">
          <result name="SUCCESS">login/login.jsp</result>
          </action>
       </package>
</struts>

5、web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  <init-param>
   <param-name>struts.i18n.encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
</web-app>

0
物联天下
物联天下

求问求神!

0
虫虫
虫虫

引用来自“物联天下”的答案

1、login.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<html>
<head>
<title>登录系统</title>
<style type="text/css">
.tablebg {
 background-image: url("${pageContext.request.contextPath}/deng/img/deng.jpg");
}
body {
 background-image: url("${pageContext.request.contextPath}/deng/img/deng.jpg");
}
.font1 {
    font-size: 18px;
    font-weight:bold;
    color:  000000  //#FFFFFF
}
</style>
<link rel="stylesheet" href="<%=request.getContextPath()%>/common/extjs/resources/css/ext-all.css" type="text/css"></link>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-base.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-all.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
               function show(){
                        var username=document.getElementById("username").value;
                        var password=document.getElementById("password").value;
                        window.open("./loginmethod.action",null,"center:yes;dialogWidth:300px;dialogHeight:300px;");
               }
               function close(){
                        var username=document.getElementById("username").value;
                        var password=document.getElementById("password").value;
                        window.open("closelogin.action",null);
               }
                       
</script>
</head> 
<body>
<form id="loginform" method="post">
<table width="10%" height="10%" align="center" valign="middle">
     <tr>
     <td width="250" height="100">
     </td>
     </tr>
     <tr>
     <td width="250" height="100">
     <font face="宋体" size="16" color="red">
     &nbsp&nbsp登&nbsp录&nbsp系&nbsp统&nbsp
     </font>
     </td>
     </tr>
</table>
<table width="10%" height="10%" align="center" valign="middle">
     <tr>
     <td width="250" height="5" align="center" valign="top">
     <font face="宋体" color="blue">
             用&nbsp户&nbsp<input type="text" id="usernamer" size="22">
     </font>
     </td>
     </tr>
     <tr>
     <td width="250" height="5" align="center" valign="top">
     <font face="宋体" color="blue">
             密&nbsp码&nbsp<input type="text" id="password" size="22">
     </font>
     </td>
     </tr>
     <tr>
     <td width="250" height="5" align="center" valign="middle">
     <font face="宋体">
     &nbsp&nbsp&nbsp&nbsp&nbsp<input type="button" value="登陆" onclick="show()">
     &nbsp<input type="button" value="关闭" onclick="close()">
     </font>
     </td>
     </tr>
</table>
</form>
</body>
</html>

2、登录成功跳转的页面11.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
李白诗赋
</title>
</head>
<table width="20%" height="20%" align="center" valign="top">
    <tr>
         <td width="250" height="250" align="center"></td>
    </tr>
    <tr>
         <td width="250" height="50" align="center">
          <font face="黑体" size="4" color="red">子秋夜歌&nbsp&nbsp&nbsp&nbsp</font></td>
    </tr> 
    <tr> 
    <tr>
         <td width="250" height="50" align="center">
          <font face="黑体" color="blue">长安一片月,万户捣衣声。</font></td>
    </tr> 
    <tr>
         <td width="250" height="50" align="center">
         <font face="黑体" color="blue">秋风吹不尽,总是玉关情。</font></td>
    </tr>
    </tr>
         <td width="250" height="50" align="center">
         <font face="黑体" color="blue">何日平胡虏,良人罢远征。</font></td>
    </tr>
</table>   
</html> 

3、login.action
package deng.action;
public class loginAction {
   private String username;
         private String password;
         public String getUsername(){
          return username;
         }
         public void setUsername(String username)
         {
          this.username=username;
         }
         public String getPassword(){
          return password;
         }
         public void setPassword(String password){
          this.password=password;
         }
         public String loginMethod(){
          String uid=getUsername();
          String pwd=getPassword();
          String L=(uid+pwd);
          if(L!=null){
        return "SUCCESS";
          }
          return "NONE";
         }
         public String closeLogin(){
          return "SUCCESS";
         }
}

4、struts-login.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<struts>
       <package name="deng.action" extends="json-default">
          <action name="loginmethod" class="loginAction" method="loginmethod">
          <result name="SUCCESS" >login/11Jsp.jsp</result>
          <result name="NONE">login/login.jsp</result>
          </action>
          <action name="closelogin" class="loginAction" method="closelogin">
          <result name="SUCCESS">login/login.jsp</result>
          </action>
       </package>
</struts>

5、web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  <init-param>
   <param-name>struts.i18n.encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
</web-app>

这叫代码上色嘛。。。

1、login.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<html>
<head>
<title>登录系统</title>
<style type="text/css">
.tablebg {
 background-image: url("${pageContext.request.contextPath}/deng/img/deng.jpg");
}
body {
 background-image: url("${pageContext.request.contextPath}/deng/img/deng.jpg");
}
.font1 {
    font-size: 18px;
    font-weight:bold;
    color:  000000  //#FFFFFF
}
</style>
<link rel="stylesheet" href="<%=request.getContextPath()%>/common/extjs/resources/css/ext-all.css" type="text/css"></link>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-base.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-all.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/extjs/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
               function show(){
                        var username=document.getElementById("username").value;
                        var password=document.getElementById("password").value;
                        window.open("./loginmethod.action",null,"center:yes;dialogWidth:300px;dialogHeight:300px;");
               }
               function close(){
                        var username=document.getElementById("username").value;
                        var password=document.getElementById("password").value;
                        window.open("closelogin.action",null);
               }
                       
</script>
</head> 
<body>
<form id="loginform" method="post">
<table width="10%" height="10%" align="center" valign="middle">
     <tr>
     <td width="250" height="100">
     </td>
     </tr>
     <tr>
     <td width="250" height="100">
     <font face="宋体" size="16" color="red">
     &nbsp&nbsp登&nbsp录&nbsp系&nbsp统&nbsp
     </font>
     </td>
     </tr>
</table>
<table width="10%" height="10%" align="center" valign="middle">
     <tr>
     <td width="250" height="5" align="center" valign="top">
     <font face="宋体" color="blue">
             用&nbsp户&nbsp<input type="text" id="usernamer" size="22">
     </font>
     </td>
     </tr>
     <tr>
     <td width="250" height="5" align="center" valign="top">
     <font face="宋体" color="blue">
             密&nbsp码&nbsp<input type="text" id="password" size="22">
     </font>
     </td>
     </tr>
     <tr>
     <td width="250" height="5" align="center" valign="middle">
     <font face="宋体">
     &nbsp&nbsp&nbsp&nbsp&nbsp<input type="button" value="登陆" onclick="show()">
     &nbsp<input type="button" value="关闭" onclick="close()">
     </font>
     </td>
     </tr>
</table>
</form>
</body>
</html>

2、登录成功跳转的页面11.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
李白诗赋
</title>
</head>
<table width="20%" height="20%" align="center" valign="top">
    <tr>
         <td width="250" height="250" align="center"></td>
    </tr>
    <tr>
         <td width="250" height="50" align="center">
          <font face="黑体" size="4" color="red">子秋夜歌&nbsp&nbsp&nbsp&nbsp</font></td>
    </tr> 
    <tr> 
    <tr>
         <td width="250" height="50" align="center">
          <font face="黑体" color="blue">长安一片月,万户捣衣声。</font></td>
    </tr> 
    <tr>
         <td width="250" height="50" align="center">
         <font face="黑体" color="blue">秋风吹不尽,总是玉关情。</font></td>
    </tr>
    </tr>
         <td width="250" height="50" align="center">
         <font face="黑体" color="blue">何日平胡虏,良人罢远征。</font></td>
    </tr>
</table>   
</html>  

3、login.action

package deng.action;
public class loginAction {
   private String username;
         private String password;
         public String getUsername(){
          return username;
         }
         public void setUsername(String username)
         {
          this.username=username;
         }
         public String getPassword(){
          return password;
         }
         public void setPassword(String password){
          this.password=password;
         }
         public String loginMethod(){
          String uid=getUsername();
          String pwd=getPassword();
          String L=(uid+pwd);
          if(L!=null){
        return "SUCCESS";
          }
          return "NONE";
         }
         public String closeLogin(){
          return "SUCCESS";
         }
}

4、struts-login.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<struts>
       <package name="deng.action" extends="json-default">
          <action name="loginmethod" class="loginAction" method="loginmethod">
          <result name="SUCCESS" >login/11Jsp.jsp</result>
          <result name="NONE">login/login.jsp</result>
          </action>
          <action name="closelogin" class="loginAction" method="closelogin">
          <result name="SUCCESS">login/login.jsp</result>
          </action>
       </package>
</struts>

5、web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  <init-param>
   <param-name>struts.i18n.encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
</web-app>

物联天下
物联天下
@虫虫 : 呵呵,小弟初学JAVA,菜鸟一个,唯有勤奋求知,呵呵
虫虫
虫虫
@物联天下 : 其实我想说的是,如果你连贴代码都搞不定,那估计这个jsp问题你也是搞不定的。。。
物联天下
物联天下
还能截个图啊,大哥
虫虫
虫虫
@物联天下 : 编辑器上面的那一排编辑按钮,中间偏右的地方有一个插入代码按钮。
物联天下
物联天下
这个具体怎么操作的呢,不懂,请大神指导哈
0
0
往事白云边
往事白云边
哈哈 严重跑题了额!~
返回顶部
顶部