萌新刚学nutz,照着教程一步一步走过来,但第一个小东西就出了问题,welcome-file-list中明明设置了index.jsp,但是运行后就是显示404错误,请各位大佬指教。
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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<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>
<display-name>nutzbook</display-name>
<filter>
<filter-name>nutz</filter-name>
<filter-class>org.nutz.mvc.NutFilter</filter-class>
<init-param>
<param-name>modules</param-name>
<param-value>net.wendal.nutzbook.MainModule</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>nutz</filter-name>
<url-pattern>/*</url-pattern>
<!-- ForwardView需要下面的配置 @Ok("->:/xxx/yyy/zzz") -->
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
</web-app>
index.jsp代码如下
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:forward page="/index.html" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>NutzBook demo</title>
<!-- 导入jquery -->
<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js"></script>
<!-- 把user id复制到一个js变量 -->
<script type="text/javascript">
var me = '<%=session.getAttribute("me") %>';
var base = '${base}';
$(function() {
$("#login_button").click(function() {
$.ajax({
url : base + "/user/login",
type: "POST",
data:$('#loginForm').serialize(),
error: function(request) {
alert("Connection error");
},
dataType:"json",
success: function(data) {
alert(data);
if (data == true) {
alert("登陆成功");
location.reload();
} else {
alert("登陆失败,请检查账号密码")
}
}
});
return false;
});
if (me != "null") {
$("#login_div").hide();
$("#userInfo").html("您的Id是" + me);
$("#user_info_div").show();
} else {
$("#login_div").show();
$("#user_info_div").hide();
}
});
</script>
</head>
<body>
<div id="login_div">
<form action="#" id="loginForm" method="post">
用户名 <input name="username" type="text" value="admin">
密码 <input name="password" type="password" value="123456">
<button id="login_button">提交</button>
</form>
</div>
<div id="user_info_div">
<p id="userInfo"></p>
<a href="${base}/user/logout">登出</a>
</div>
</body>
</html>