spring3 mvc系列一:架构基本配置(注解版)

展开阅读全文

spring3 mvc 注解

11-08

web.xmlrn[code=XML]rnrnrn rn defaultrn *.jpgrn rn rn defaultrn *.pngrn rn rn defaultrn *.gifrn rn rn defaultrn *.jsrn rn rn defaultrn *.cssrn rn rn springrn org.springframework.web.servlet.DispatcherServletrn 1rn rn rn springrn /rn rn rn login.jsprn rnrn[/code]rnspring-servlet.xmlrn[code=XML]rnrnrn rn rn rn rnrn rn rn rn rn rn rnrn rnrn rn rnrnrn[/code]rn[code=Java]package cn.spring.app.controller;rnrnimport javax.servlet.http.HttpServletRequest;rnrnimport org.springframework.stereotype.Controller;rnimport org.springframework.web.bind.annotation.RequestMapping;rnimport org.springframework.web.bind.annotation.RequestMethod;rnrnrn@Controllerrnpublic class LoginController rn @RequestMapping(value="/login",method=RequestMethod.GET)rn public String login()rn return "login";rn rn @RequestMapping(value="/login",method=RequestMethod.POST)rn public String login2(HttpServletRequest request)rn String username=request.getParameter("username").trim();rn System.out.println(username);rn return "success";rn rnrn[/code]rn[code=Java]rnpackage cn.spring.app.model;rnrnpublic class User rn private String userId;rn private String userName;rn private String userPassword;rnrn public String getUserId() rn return userId;rn rnrn public void setUserId(String userId) rn this.userId = userId;rn rnrn public String getUserName() rn return userName;rn rnrn public void setUserName(String userName) rn this.userName = userName;rn rnrn public String getUserPassword() rn return userPassword;rn rnrn public void setUserPassword(String userPassword) rn this.userPassword = userPassword;rn rnrnrn[/code]rn[code=JScript]rn<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>rnrnrnrn rn Insert title herernrnrn rn ID号: rn 密码: rn rn rnrnrn[/code]rn这些就是我的配置,总是报404错误,大虾们如何解决啊? 论坛

没有更多推荐了,返回首页