我目前正在做两个页面之间的跳转,可运行的时候老是出现空白,我把代码列出来请各位大侠,帮我看看哪出了问题:
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">
  登 录 系 统 
</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">
用 户 <input type="text" id="usernamer" size="22">
</font>
</td>
</tr>
<tr>
<td width="250" height="5" align="center" valign="top">
<font face="宋体" color="blue">
密 码 <input type="text" id="password" size="22">
</font>
</td>
</tr>
<tr>
<td width="250" height="5" align="center" valign="middle">
<font face="宋体">
     <input type="button" value="登陆" onclick="show()">
 <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">子秋夜歌    </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,请各位大神多多指点,小弟就感激涕零了
引用来自“物联天下”的答案
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">
  登 录 系 统 
</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">
用 户 <input type="text" id="usernamer" size="22">
</font>
</td>
</tr>
<tr>
<td width="250" height="5" align="center" valign="top">
<font face="宋体" color="blue">
密 码 <input type="text" id="password" size="22">
</font>
</td>
</tr>
<tr>
<td width="250" height="5" align="center" valign="middle">
<font face="宋体">
     <input type="button" value="登陆" onclick="show()">
 <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">子秋夜歌    </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
2、登录成功跳转的页面11.jsp
3、login.action
4、struts-login.xml文件
5、web.xml
求问求神!
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">
  登 录 系 统 
</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">
用 户 <input type="text" id="usernamer" size="22">
</font>
</td>
</tr>
<tr>
<td width="250" height="5" align="center" valign="top">
<font face="宋体" color="blue">
密 码 <input type="text" id="password" size="22">
</font>
</td>
</tr>
<tr>
<td width="250" height="5" align="center" valign="middle">
<font face="宋体">
     <input type="button" value="登陆" onclick="show()">
 <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">子秋夜歌    </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>
运行的时候没有问题,但页面无法显示出来