HttpServletRequest获取URL get变量
来源:互联网 发布:开票软件金税盘版升级 编辑:程序博客网 时间:2024/06/04 18:30
helloController.java
package cn.han.controller;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.servlet.ModelAndView;@Controllerpublic class helloController {@RequestMapping("/hello/1")public ModelAndView hello(HttpServletRequest req,HttpServletResponse rep){String var1=req.getParameter("var1");ModelAndView mV=new ModelAndView();mV.addObject("msg","Hello Spring Mvc Annotation Demo");mV.addObject("var1", var1);mV.setViewName("hello");return mV;}}
WEB-INF/jsp/hello.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'hello.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--> </head> <body> This is my JSP page. <br> ${msg}<br/> ${var1} </body></html>
运行,输入
http://han-pc:8080/03Springmvc_Demo/hello/1.html?var1=This GET Parameter
输出
This is my JSP page.
Hello Spring Mvc Annotation Demo
This GET Parameter
下面讲一个常见的部署错误解决办法
An internal error occurred during: "Launching XXXX on Tomcat 6.x".
java.lang.NullPointerException
错误报告:
java.lang.NullPointerException
at com.genuitec.eclipse.ast.deploy.core.Deployment.<init>(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.ModuleDeployment.<init>(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.WebDeployment.<init>(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.Deployment.create(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.DeploymentManager.loadFromPreferences(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.DeploymentManager.init(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.DeploymentManager.<init>(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.DeploymentManager.getDefault(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.ui.ServerTreeViewer$ServerTreeContentProvider.inputChanged(Unknown Source)
at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:276)
at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1690)
at com.genuitec.eclipse.ast.deploy.core.ui.ServerTreeViewer.<init>(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.ui.ServerView.createPartControl(Unknown Source)
at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:375)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:229)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.handlers.ShowViewHandler.openView(ShowViewHandler.java:145)
at org.eclipse.ui.handlers.ShowViewHandler.execute(ShowViewHandler.java:76)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
1、首先关闭MyEclipse工作空间。
2、然后删除工作空间下的
“/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.genuitec.eclipse.ast.deploy.core.prefs”
这个文件。在这个文件中存储了一些部署项目的信息。删了这个部署的项目的信息就没有错误了。
3、重启启动MyEclipse即可解决了。
- HttpServletRequest获取URL get变量
- HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL相关的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest——获取URL的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL的方法
- 【javaWeb】HttpServletRequest常用获取URL的方法
- HttpServletRequest常用获取URL的方法
- HttpServletRequest获取URL的相关方法
- HttpServletRequest常用获取URL的方法
- 【转】HashMap源码解析
- iOS开发之关于Runtime运行时:类与对象
- 启动tomcat出现 a java Exception has occured 解决方法
- Fragment
- Java中的反射机制
- HttpServletRequest获取URL get变量
- PHP基础教程3
- weak和assign的区别
- Things You Should Never Do, Part I
- Avalanche:quand la neige devient dangereuse?
- Android 开源项目浅读-------SwipeMenuListView-重写,第四章,修改适配器
- 系统属性调用评估方法介绍
- xss攻击入门详情
- 107[Leetcode].Binary Tree Level Order Traversal II